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-Tag: accepted/trunk/20130322.191538~38041^2~401 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc28f22bb2b1060caded9429d0b1ed07e8890332;p=platform%2Fupstream%2Fperl.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';