From a8c819d907340e1b10f2dc8baf524e05533e951d Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Tue, 13 Dec 2016 04:18:45 +0000 Subject: dvipsk: Fix a bug leading to wrong strlen (emstr). Thanks Norbert Klingen. git-svn-id: svn://tug.org/texlive/trunk@42692 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipsk/ChangeLog | 6 ++++++ Build/source/texk/dvipsk/emspecial.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'Build/source/texk') diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index c5f40d2c94e..8299e31e761 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,9 @@ +2016-12-13 Akira Kakuto + + * emspecial.c: Initialize emstr[500] in emspecial(), to fix wrong + strlen (emstr). Reported by Norbert Klingen: + http://tug.org/pipermail/tex-live/2016-December/039483.html. + 2016-11-08 Karl Berry * dvips.texi, diff --git a/Build/source/texk/dvipsk/emspecial.c b/Build/source/texk/dvipsk/emspecial.c index 3210a8a2639..e3d66431c08 100644 --- a/Build/source/texk/dvipsk/emspecial.c +++ b/Build/source/texk/dvipsk/emspecial.c @@ -145,6 +145,22 @@ char emunit[30]; char emstr[500]; char *emp; +/* Initialize emstr[500] because emstr in the code below may not + be a right string, leading to wrong strlen(emstr): + + if (strlen(emstr) - 2 >= sizeof(emstr)) { + fprintf(stderr, "em:graph: special too long, truncating\n"); + break; + } + emstr[i++] = *emp; + } +*/ + { + int k; + for (k = 0; k < 500; k++) + emstr[k] = '\0'; + } + hvpos(); for (emp = p+3; *emp && isspace((unsigned char)*emp); emp++); /* skip blanks */ if (strncmp(emp, "linewidth", 9) == 0) { -- cgit v1.2.3