summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorGisle Aas <gisle@aas.no>1998-07-18 00:49:32 +0200
committerGurusamy Sarathy <gsar@cpan.org>1998-07-19 07:04:45 +0000
commite670df4e079ef573ed96c8dda3854ce6b6e45588 (patch)
tree8d93db181a67ed3c2faff3815e1eaa89bbd3733f /sv.c
parent9424984c2ada47d2d3079139512891e548612e00 (diff)
downloadperl-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.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/sv.c b/sv.c
index 29c45fd37a..a54c6baea7 100644
--- a/sv.c
+++ b/sv.c
@@ -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)) {