From: Gisle Aas Date: Sun, 9 Feb 1997 10:55:41 +0000 (+0100) Subject: Re: static buffer in not_a_number() [sv.c] might overflow X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dc28f22bb2b1060caded9429d0b1ed07e8890332;p=p5sagit%2Fp5-mst-13.2.git Re: static buffer in not_a_number() [sv.c] might overflow p5p-msgid: --- diff --git a/sv.c b/sv.c index 5adbe8a..528afd9 100644 --- a/sv.c +++ b/sv.c @@ -1195,9 +1195,11 @@ SV *sv; char tmpbuf[64]; char *d = tmpbuf; char *s; - int i; + char *limit = tmpbuf + sizeof(tmpbuf) - 8; + /* each *s can expand to 4 chars + "...\0", + i.e. need room for 8 chars */ - for (s = SvPVX(sv), i = 50; *s && i; s++,i--) { + for (s = SvPVX(sv); *s && d < limit; s++) { int ch = *s & 0xFF; if (ch & 128 && !isPRINT_LC(ch)) { *d++ = 'M';