develooper Front page | perl.perl5.porters | Postings from November 2003

[PATCH] setting $0 still broken

Thread Next
From:
Jan Dubois
Date:
November 27, 2003 21:12
Subject:
[PATCH] setting $0 still broken
Message ID:
f3mdsv8dcv4asle0kbhiijk0adu1l25sr3@4ax.com
After change #21664 the trailing '\0' on PL_origargv[0] may be overwritten
by a space.  I don't understand why the spaces are necessary, but they
still need to be '\0' terminated, otherwise t.op/magic.t #35 and
ext/threads/join.t #11 will fail.  The attached patch fixes this.

I've also moved the code that nulls out PL_origargv.  I don't understand
how this code is used (PL_origargv doesn't seem to be accessed again), but
if nulling is required when part of the data is overwritten, then it
should also be needed when all the data is overwritten.

Cheers,
-Jan

Index: mg.c
--- mg.c.~1~   Thu Nov 27 20:16:01 2003
+++ mg.c       Thu Nov 27 20:16:01 2003
@@ -2415,7 +2415,6 @@
            /* 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. */
@@ -2428,9 +2427,10 @@
                    * --jhi */
                   (int)' ',
                   PL_origalen - len - 1);
-           for (i = 1; i < PL_origargc; i++)
-                PL_origargv[i] = 0;
        }
+        PL_origargv[0][PL_origalen-1] = 0;
+        for (i = 1; i < PL_origargc; i++)
+            PL_origargv[i] = 0;
        UNLOCK_DOLLARZERO_MUTEX;
        break;
 #endif
End of Patch.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About