summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-05-19 01:44:14 +0300
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-05-19 15:17:00 +0000
commit1208b3dd78273b01e1538ddb951ee4e62eb90ebe (patch)
tree38b5fd268f3dd503750957b8f5624f81f9f86289 /perlio.c
parentcf228a9d2f82a9bc6f66fb739370ed1847034425 (diff)
downloadperl-1208b3dd78273b01e1538ddb951ee4e62eb90ebe.tar.gz
Re: [PATCH] Re: Change 28183 has broken 64-bit builds?
Message-ID: <446CCE8E.8010407@gmail.com> p4raw-id: //depot/perl@28234
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/perlio.c b/perlio.c
index 9e06ef1856..a0cb4a4d05 100644
--- a/perlio.c
+++ b/perlio.c
@@ -478,9 +478,9 @@ PerlIO_debug(const char *fmt, ...)
const char * const s = CopFILE(PL_curcop);
/* Use fixed buffer as sv_catpvf etc. needs SVs */
char buffer[1024];
- const STRLEN len = my_sprintf(buffer, "%.40s:%" IVdf " ", s ? s : "(none)", (IV) CopLINE(PL_curcop));
- const STRLEN len2 = my_vsnprintf(buffer+len, sizeof(buffer) - len, fmt, ap);
- PerlLIO_write(PL_perlio_debug_fd, buffer, len + len2);
+ const STRLEN len1 = my_snprintf(buffer, sizeof(buffer), "%.40s:%" IVdf " ", s ? s : "(none)", (IV) CopLINE(PL_curcop));
+ const STRLEN len2 = my_vsnprintf(buffer + len1, sizeof(buffer) - len1, fmt, ap);
+ PerlLIO_write(PL_perlio_debug_fd, buffer, len1 + len2);
#else
const char *s = CopFILE(PL_curcop);
STRLEN len;
@@ -5144,14 +5144,12 @@ PerlIO_vsprintf(char *s, int n, const char *fmt, va_list ap)
{
dTHX;
const int val = my_vsnprintf(s, n > 0 ? n : 0, fmt, ap);
- if (n >= 0) {
- if (strlen(s) >= (STRLEN) n) {
- dTHX;
- (void) PerlIO_puts(Perl_error_log,
- "panic: sprintf overflow - memory corrupted!\n");
- my_exit(1);
- }
+#ifndef PERL_MY_VSNPRINTF_GUARDED
+ if (val < 0 || (n > 0 ? val >= n : 0)) {
+ dTHX;
+ Perl_croak("panic: my_vsnprintf overflow in PerlIO_vsprintf\n");
}
+#endif
return val;
}
#endif