X-Git-Url: http://git.savannah.gnu.org/gitweb/?p=enscript.git;a=blobdiff_plain;f=src%2Fpsgen.c;h=21e4c755e47db01f295ada7fa2b3ee2082f1b41c;hp=b827fe10aff66ac540e5aade687c2496ead9dbef;hb=3cdbcb6ae69304350294ec250d84b6ce9ea688b0;hpb=0acc7b63a1be9f5d02f1a21d6df52cb5a9ce7e58 diff --git a/src/psgen.c b/src/psgen.c index b827fe1..21e4c75 100644 --- a/src/psgen.c +++ b/src/psgen.c @@ -22,6 +22,7 @@ * along with Enscript. If not, see . */ +#include #include "gsint.h" #include @@ -123,7 +124,7 @@ struct gs_token_st double xscale; double yscale; int llx, lly, urx, ury; /* Bounding box. */ - char filename[512]; + char filename[PATH_MAX]; char *skipbuf; unsigned int skipbuf_len; unsigned int skipbuf_pos; @@ -134,11 +135,11 @@ struct gs_token_st Color bgcolor; struct { - char name[512]; + char name[PATH_MAX]; FontPoint size; InputEncoding encoding; } font; - char filename[512]; + char filename[PATH_MAX]; } u; }; @@ -247,7 +248,7 @@ static int do_print = 1; static int user_fontp = 0; /* The user ^@font{}-defined font. */ -static char user_font_name[256]; +static char user_font_name[PATH_MAX]; static FontPoint user_font_pt; static InputEncoding user_font_encoding; @@ -279,12 +280,19 @@ dump_ps_header () { char *cp, *cp2; int i, j, got; + char *ps_version_string; /* Version string for PS procsets. */ + /* Dump PS header only once. */ if (ps_header_dumped) return; ps_header_dumped = 1; + /* Create version string. */ + ps_version_string = xstrdup (VERSION); + cp = strrchr (ps_version_string, '.'); + *cp = ' '; + /* * Header. */ @@ -294,7 +302,7 @@ dump_ps_header () media->urx, media->ury)); OUTPUT ((cofp, "%%%%Title: %s\n", title)); OUTPUT ((cofp, "%%%%For: %s\n", passwd->pw_gecos)); - OUTPUT ((cofp, "%%%%Creator: %s\n", version_string)); + OUTPUT ((cofp, "%%%%Creator: %s\n", PACKAGE_STRING)); OUTPUT ((cofp, "%%%%CreationDate: %s\n", date_string)); OUTPUT ((cofp, "%%%%Orientation: %s\n", ((nup > 1) && nup_landscape) @@ -977,7 +985,8 @@ large for page\n"), FATAL ((stderr, _("user font encoding can be only the system's default or `ps'"))); - strcpy (user_font_name, token.u.font.name); + memset (user_font_name, 0, sizeof(user_font_name)); + strncpy (user_font_name, token.u.font.name, sizeof(user_font_name) - 1); user_font_pt.w = token.u.font.size.w; user_font_pt.h = token.u.font.size.h; user_font_encoding = token.u.font.encoding; @@ -1443,7 +1452,7 @@ read_special_escape (InputStream *is, Token *token) buf[i] = ch; if (i + 1 >= sizeof (buf)) FATAL ((stderr, _("too long argument for %s escape:\n%.*s"), - escapes[i].name, i, buf)); + escapes[e].name, i, buf)); } buf[i] = '\0'; @@ -1451,7 +1460,8 @@ read_special_escape (InputStream *is, Token *token) switch (escapes[e].escape) { case ESC_FONT: - strcpy (token->u.font.name, buf); + memset (token->u.font.name, 0, sizeof(token->u.font.name)); + strncpy (token->u.font.name, buf, sizeof(token->u.font.name) - 1); /* Check for the default font. */ if (strcmp (token->u.font.name, "default") == 0) @@ -1464,7 +1474,8 @@ read_special_escape (InputStream *is, Token *token) FATAL ((stderr, _("malformed font spec for ^@font escape: %s"), token->u.font.name)); - strcpy (token->u.font.name, cp); + memset (token->u.font.name, 0, sizeof(token->u.font.name)); + strncpy (token->u.font.name, cp, sizeof(token->u.font.name) - 1); xfree (cp); } token->type = tFONT; @@ -1543,7 +1554,8 @@ read_special_escape (InputStream *is, Token *token) break; case ESC_SETFILENAME: - strcpy (token->u.filename, buf); + memset (token->u.filename, 0, sizeof(token->u.filename)); + strncpy (token->u.filename, buf, sizeof(token->u.filename) - 1); token->type = tSETFILENAME; break;