Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jun 2016 18:12:11 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r301807 - stable/9/lib/libmp
Message-ID:  <201606101812.u5AICB5j025799@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606101812.u5AICB5j025799>