diff options
author | Gisle Aas <gisle@aas.no> | 1998-07-18 00:49:32 +0200 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-19 07:04:45 +0000 |
commit | e670df4e079ef573ed96c8dda3854ce6b6e45588 (patch) | |
tree | 8d93db181a67ed3c2faff3815e1eaa89bbd3733f /sv.c | |
parent | 9424984c2ada47d2d3079139512891e548612e00 (diff) | |
download | perl-e670df4e079ef573ed96c8dda3854ce6b6e45588.tar.gz |
sv_gets() did not NUL-terminate SV when reading records
Message-ID: <m390lsb3tv.fsf@furu.g.aas.no>
p4raw-id: //depot/perl@1564
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -3239,12 +3239,7 @@ sv_gets(register SV *sv, register PerlIO *fp, I32 append) /* Grab the size of the record we're getting */ recsize = SvIV(SvRV(rs)); (void)SvPOK_only(sv); /* Validate pointer */ - /* Make sure we've got the room to yank in the whole thing */ - if (SvLEN(sv) <= recsize + 3) { - /* No, so make it bigger */ - SvGROW(sv, recsize + 3); - } - buffer = SvPVX(sv); /* Get the location of the final buffer */ + buffer = SvGROW(sv, recsize + 1); /* Go yank in */ #ifdef VMS /* VMS wants read instead of fread, because fread doesn't respect */ @@ -3255,6 +3250,7 @@ sv_gets(register SV *sv, register PerlIO *fp, I32 append) bytesread = PerlIO_read(fp, buffer, recsize); #endif SvCUR_set(sv, bytesread); + buffer[bytesread] = '\0'; return(SvCUR(sv) ? SvPVX(sv) : Nullch); } else if (RsPARA(rs)) { |