diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-08-02 09:16:55 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-08-02 09:16:55 +0000 |
commit | f264d47263c7375271aa7881cc3559ec63be6afa (patch) | |
tree | ec534a4be1b162e14c04e921e3055960ee1cd488 /pp.c | |
parent | 6e24577b73349d1aafc95909524a5bfa8e672bb5 (diff) | |
download | perl-f264d47263c7375271aa7881cc3559ec63be6afa.tar.gz |
fix longstanding bug in pack('u',...) (reads garbage beyond the end
of the input string)
p4raw-id: //depot/maint-5.005/perl@1712
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -3653,7 +3653,7 @@ doencodes(register SV *sv, register char *s, register I32 len) *hunk = uuemap[len]; sv_catpvn(sv, hunk, 1); hunk[4] = '\0'; - while (len > 0) { + while (len > 2) { hunk[0] = uuemap[(077 & (*s >> 2))]; hunk[1] = uuemap[(077 & ((*s << 4) & 060 | (s[1] >> 4) & 017))]; hunk[2] = uuemap[(077 & ((s[1] << 2) & 074 | (s[2] >> 6) & 03))]; @@ -3662,6 +3662,14 @@ doencodes(register SV *sv, register char *s, register I32 len) s += 3; len -= 3; } + if (len > 0) { + char r = (len > 1 ? s[1] : '\0'); + hunk[0] = uuemap[(077 & (*s >> 2))]; + hunk[1] = uuemap[(077 & ((*s << 4) & 060 | (r >> 4) & 017))]; + hunk[2] = uuemap[(077 & ((r << 2) & 074))]; + hunk[3] = uuemap[0]; + sv_catpvn(sv, hunk, 4); + } sv_catpvn(sv, "\n", 1); } |