On Mon, 27 Oct 2003 02:30:00 -0800, Abhijit Menon-Sen <ams@wiw.org> wrote: >Change 21546 by ams@lustre on 2003/10/27 09:00:08 > > Will the real off by one please stand up? I believe this patch is wrong. The previous patch (#21538) already fixed the problem correctly. The calculation in perl.c doesn't include the final trailing '\0' character in PL_origalen. If you prefer to have PL_origalen to be the complete buffer length, please add a patch to perl.c along the lines of: - PL_origalen = s - PL_origargv[0]; + PL_origalen = s - PL_origargv[0] + 1; Otherwise please back out change #21546. I have an application that embeds Perl and provides a non-contiguous argv. After change #21546 just assigning $0 to itself in that application truncates it by one character. Cheers, -Jan >Affected files ... > >... //depot/perl/mg.c#281 edit > >Differences ... > >==== //depot/perl/mg.c#281 (text) ==== >Index: perl/mg.c >--- perl/mg.c#280~21538~ Sun Oct 26 01:08:02 2003 >+++ perl/mg.c Mon Oct 27 01:00:08 2003 >@@ -2400,10 +2400,11 @@ > #endif > /* PL_origalen is set in perl_parse(). */ > s = SvPV_force(sv,len); >- if (len >= (STRLEN)PL_origalen) { >- /* Longer than original, will be truncated. */ >- Copy(s, PL_origargv[0], PL_origalen, char); >- PL_origargv[0][PL_origalen] = 0; >+ if (len >= (STRLEN)PL_origalen-1) { >+ /* Longer than original, will be truncated. We assume that >+ * PL_origalen bytes are available. */ >+ Copy(s, PL_origargv[0], PL_origalen-1, char); >+ PL_origargv[0][PL_origalen-1] = 0; > } > else { > /* Shorter than original, will be padded. */ >End of Patch.Thread Next