From: Nick Ing-Simmons Date: Tue, 16 Oct 2001 17:31:47 +0000 (+0000) Subject: When USE_ITHREADS avoid SV * in PerlIO_debug, at risk of buffer X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=70ace5dac0395f9f5ca5478d23db8cd1e0dbd6e7;p=p5sagit%2Fp5-mst-13.2.git When USE_ITHREADS avoid SV * in PerlIO_debug, at risk of buffer overflow. p4raw-id: //depot/perlio@12460 --- diff --git a/perlio.c b/perlio.c index 0349795..4f79b71 100644 --- a/perlio.c +++ b/perlio.c @@ -300,6 +300,19 @@ PerlIO_debug(const char *fmt, ...) } if (dbg > 0) { dTHX; +#ifdef USE_ITHREADS + /* Use fixed buffer as sv_catpvf etc. needs SVs */ + char buffer[1024]; + char *s; + STRLEN len; + s = CopFILE(PL_curcop); + if (!s) + s = "(none)"; + sprintf(buffer, "%s:%" IVdf " ", s, (IV) CopLINE(PL_curcop)); + len = strlen(buffer); + vsprintf(buffer+len, fmt, ap); + PerlLIO_write(dbg, buffer, strlen(buffer)); +#else SV *sv = newSVpvn("", 0); char *s; STRLEN len; @@ -313,6 +326,7 @@ PerlIO_debug(const char *fmt, ...) s = SvPV(sv, len); PerlLIO_write(dbg, s, len); SvREFCNT_dec(sv); +#endif } va_end(ap); }