Author: bdrewery
Date: Thu Oct  2 18:11:13 2014
New Revision: 272434
URL: https://svnweb.freebsd.org/changeset/base/272434

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
  Approved by:  re (gjb)

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

Modified: stable/10/sbin/savecore/savecore.c
==============================================================================
--- stable/10/sbin/savecore/savecore.c  Thu Oct  2 18:09:31 2014        
(r272433)
+++ stable/10/sbin/savecore/savecore.c  Thu Oct  2 18:11:13 2014        
(r272434)
@@ -151,7 +151,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);
        }
@@ -160,6 +163,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);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to