Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jun 2016 17:57:56 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r301156 - stable/10/usr.sbin/tzsetup
Message-ID:  <201606011757.u51Hvudm064317@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Wed Jun  1 17:57:56 2016
New Revision: 301156
URL: https://svnweb.freebsd.org/changeset/base/301156

Log:
  MFC r300706
  
  Avoid buffer overflow or truncation when constructing path_zoneinfo_file.
  
  Reported by:	Coverity
  CID:		1011160

Modified:
  stable/10/usr.sbin/tzsetup/tzsetup.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/tzsetup/tzsetup.c
==============================================================================
--- stable/10/usr.sbin/tzsetup/tzsetup.c	Wed Jun  1 17:47:34 2016	(r301155)
+++ stable/10/usr.sbin/tzsetup/tzsetup.c	Wed Jun  1 17:57:56 2016	(r301156)
@@ -837,7 +837,9 @@ install_zoneinfo(const char *zoneinfo)
 	FILE		*f;
 	char		path_zoneinfo_file[MAXPATHLEN];
 
-	sprintf(path_zoneinfo_file, "%s/%s", path_zoneinfo, zoneinfo);
+	if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file),
+	    "%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file))
+		errx(1, "%s/%s name too long", path_zoneinfo, zoneinfo);
 	rv = install_zoneinfo_file(path_zoneinfo_file);
 
 	/* Save knowledge for later */



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