Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Apr 2017 14:51:54 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317371 - head/contrib/elftoolchain/elfcopy
Message-ID:  <201704241451.v3OEpsfa014026@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Mon Apr 24 14:51:53 2017
New Revision: 317371
URL: https://svnweb.freebsd.org/changeset/base/317371

Log:
  elfcopy: allow empty symbol list files
  
  Reported by:	bz
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D10441

Modified:
  head/contrib/elftoolchain/elfcopy/main.c

Modified: head/contrib/elftoolchain/elfcopy/main.c
==============================================================================
--- head/contrib/elftoolchain/elfcopy/main.c	Mon Apr 24 12:52:42 2017	(r317370)
+++ head/contrib/elftoolchain/elfcopy/main.c	Mon Apr 24 14:51:53 2017	(r317371)
@@ -1285,8 +1285,9 @@ parse_symlist_file(struct elfcopy *ecp, 
 		err(EXIT_FAILURE, "can not open %s", fn);
 	if ((data = malloc(sb.st_size + 1)) == NULL)
 		err(EXIT_FAILURE, "malloc failed");
-	if (fread(data, 1, sb.st_size, fp) == 0 || ferror(fp))
-		err(EXIT_FAILURE, "fread failed");
+	if (sb.st_size > 0)
+		if (fread(data, sb.st_size, 1, fp) != 1)
+			err(EXIT_FAILURE, "fread failed");
 	fclose(fp);
 	data[sb.st_size] = '\0';
 



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