summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-10-16 17:31:47 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-10-16 17:31:47 +0000
commit70ace5dac0395f9f5ca5478d23db8cd1e0dbd6e7 (patch)
treed1238ded9e8a1ce521133cb599a6ef21de2d8951 /perlio.c
parenta8fc9800e47fd3c23e88282f4505c051278ccc9b (diff)
downloadperl-70ace5dac0395f9f5ca5478d23db8cd1e0dbd6e7.tar.gz
When USE_ITHREADS avoid SV * in PerlIO_debug, at risk of buffer
overflow. p4raw-id: //depot/perlio@12460
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/perlio.c b/perlio.c
index 03497954d0..4f79b71c7d 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);
}