summaryrefslogtreecommitdiffstats
path: root/lib/libmp
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-06-10 18:10:32 +0000
committerngie <ngie@FreeBSD.org>2016-06-10 18:10:32 +0000
commita8c272ee059b938ef0b733dddd663d4abfc19e96 (patch)
tree4ae715a9af793f53e3d0ea626df974ced85a96b2 /lib/libmp
parent68675c854c08cbd6aeadb624b8d2bc51a0e21fe5 (diff)
downloadFreeBSD-src-a8c272ee059b938ef0b733dddd663d4abfc19e96.zip
FreeBSD-src-a8c272ee059b938ef0b733dddd663d4abfc19e96.tar.gz
MFC r299510:
r299510 (by cem): 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. CID: 1017457
Diffstat (limited to 'lib/libmp')
-rw-r--r--lib/libmp/mpasbn.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libmp/mpasbn.c b/lib/libmp/mpasbn.c
index bc5556d..2656124 100644
--- a/lib/libmp/mpasbn.c
+++ b/lib/libmp/mpasbn.c
@@ -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);
OpenPOWER on IntegriCloud