Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Oct 2014 18:12:19 +0000 (UTC)
From:      Bryan Drewery <bdrewery@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: r272435 - stable/9/sbin/savecore
Message-ID:  <201410021812.s92ICJjE021461@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Thu Oct  2 18:12:18 2014
New Revision: 272435
URL: https://svnweb.freebsd.org/changeset/base/272435

Log:
  MFC r271720:
  
    If fgets(3) fails in getbounds(), show strerror(3) if not an EOF. Also fix a
    FILE* leak in getbounds().
  
  PR:		192032

Modified:
  stable/9/sbin/savecore/savecore.c
Directory Properties:
  stable/9/sbin/savecore/   (props changed)

Modified: stable/9/sbin/savecore/savecore.c
==============================================================================
--- stable/9/sbin/savecore/savecore.c	Thu Oct  2 18:11:13 2014	(r272434)
+++ stable/9/sbin/savecore/savecore.c	Thu Oct  2 18:12:18 2014	(r272435)
@@ -149,7 +149,10 @@ getbounds(void) {
 	}
 
 	if (fgets(buf, sizeof buf, fp) == NULL) {
-		syslog(LOG_WARNING, "unable to read from bounds, using 0");
+		if (feof(fp))
+			syslog(LOG_WARNING, "bounds file is empty, using 0");
+		else
+			syslog(LOG_WARNING, "bounds file: %s", strerror(errno));
 		fclose(fp);
 		return (ret);
 	}
@@ -158,6 +161,7 @@ getbounds(void) {
 	ret = (int)strtol(buf, NULL, 10);
 	if (ret == 0 && (errno == EINVAL || errno == ERANGE))
 		syslog(LOG_WARNING, "invalid value found in bounds, using 0");
+	fclose(fp);
 	return (ret);
 }
 



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