libmp: Fix trivial buffer overrun
fgetln yields a non-NUL-terminated buffer and its length. This routine attempted to NUL-terminate it, but did not allocate space for the NUL. So, allocate space for the NUL. Reported by: Coverity CID: 1017457 Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
97f5dee540
commit
3f6e1e85c8
@ -286,10 +286,10 @@ mp_min(MINT *mp)
|
||||
line = fgetln(stdin, &linelen);
|
||||
if (line == NULL)
|
||||
MPERR(("min"));
|
||||
nline = malloc(linelen);
|
||||
nline = malloc(linelen + 1);
|
||||
if (nline == NULL)
|
||||
MPERR(("min"));
|
||||
strncpy(nline, line, linelen);
|
||||
memcpy(nline, line, linelen);
|
||||
nline[linelen] = '\0';
|
||||
rmp = _dtom("min", nline);
|
||||
_movem("min", rmp, mp);
|
||||
|
Loading…
Reference in New Issue
Block a user