From e466b85f007f70bae104d8fe0c9173a0707d1626 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 8 May 2009 16:44:52 +0000 Subject: avoid accessing unallocated memory, from Akira; prettify related errors git-svn-id: svn://tug.org/texlive/trunk@13011 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipsk/ChangeLog | 7 +++++++ Build/source/texk/dvipsk/dvips.c | 15 ++++++++------- Build/source/texk/dvipsk/resident.c | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index 7ec0655a12c..5167f50475d 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,10 @@ +2009-05-08 Karl Berry + + * resident.c (getpsinfo): avoid accessing unallocated downbuf[-1]. + * dvips.c (main): do not check iname[-1] if there is no iname. + Reports from Akira. + Also prettify some related error messages. + 2009-04-04 Karl Berry * writet1.c (append_cs_return): new fn. diff --git a/Build/source/texk/dvipsk/dvips.c b/Build/source/texk/dvipsk/dvips.c index 7f1bb9cd08e..8a310219135 100644 --- a/Build/source/texk/dvipsk/dvips.c +++ b/Build/source/texk/dvipsk/dvips.c @@ -1175,7 +1175,8 @@ default: } if (oname[0] == '-' && oname[1] == 0) oname[0] = 0 ; - else if (*oname == 0 && ! filter) { + else if (*oname == 0 && ! filter && *iname) { + /* determine output name from input name */ oname = nextstring ; #ifndef VMCMS /* get stuff before LAST "." */ lastext = strlen(iname) - 1 ; @@ -1281,21 +1282,21 @@ default: SET_BINARY(fileno(stdin)) ; } else { #ifdef KPATHSEA - fprintf (stderr, "Missing DVI file argument (or -f).\n"); - fprintf (stderr, "Try --help for more information.\n"); + fprintf (stderr, "dvips: Missing DVI file argument (or -f).\n"); + fprintf (stderr, "dvips: Try --help for more information.\n"); #else help(1) ; #endif exit(1) ; } - initcolor() ; if (dvifile==NULL) { - extern char errbuf[]; - (void)sprintf(errbuf,"! DVI file <%s> can't be opened.", iname) ; - error("! DVI file can't be opened.") ; + error_with_perror("DVI file can't be opened:", iname); + exit(1); } if (fseek(dvifile, 0L, 0) < 0) error("! DVI file must not be a pipe.") ; + + initcolor() ; #ifdef FONTLIB fliload(); /* read the font libaries */ #endif diff --git a/Build/source/texk/dvipsk/resident.c b/Build/source/texk/dvipsk/resident.c index ec3f7b4d326..9b8be0f8927 100644 --- a/Build/source/texk/dvipsk/resident.c +++ b/Build/source/texk/dvipsk/resident.c @@ -964,7 +964,7 @@ void getpsinfo P1C(char *, name) if (downloadinfo) strcat(downbuf, downloadinfo) ; slen = strlen(downbuf) - 1; - if (downbuf[slen] == ' ') { + if (slen > 0 && downbuf[slen] == ' ') { downbuf[slen] = 0; } if (TeXname) { -- cgit v1.2.3