svn commit: r301807 - stable/9/lib/libmp

Garrett Cooper ngie at FreeBSD.org
Fri Jun 10 18:12:12 UTC 2016


Author: ngie
Date: Fri Jun 10 18:12:11 2016
New Revision: 301807
URL: https://svnweb.freebsd.org/changeset/base/301807

Log:
  MFstable/10 r301806:
  
  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

Modified:
  stable/9/lib/libmp/mpasbn.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/lib/   (props changed)

Modified: stable/9/lib/libmp/mpasbn.c
==============================================================================
--- stable/9/lib/libmp/mpasbn.c	Fri Jun 10 18:10:32 2016	(r301806)
+++ stable/9/lib/libmp/mpasbn.c	Fri Jun 10 18:12:11 2016	(r301807)
@@ -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);


More information about the svn-src-all mailing list