Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Mar 2016 18:28:20 +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: r296391 - head/contrib/elftoolchain/elfcopy
Message-ID:  <201603041828.u24ISKl8076870@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Fri Mar  4 18:28:19 2016
New Revision: 296391
URL: https://svnweb.freebsd.org/changeset/base/296391

Log:
  elfcopy: fail if debug link target is empty
  
  An empty debug link target previously returned a confusing and incorrect
  error like "objcopy: fread failed: No error: 0". Now, return an explicit
  error.
  
  GNU objcopy allows an empty file as the debug link target. However,
  that case is nonsensical so diverging from GNU behaviour is fine.
  
  Reviewed by:	bdrewery
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D5541

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

Modified: head/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- head/contrib/elftoolchain/elfcopy/sections.c	Fri Mar  4 18:17:53 2016	(r296390)
+++ head/contrib/elftoolchain/elfcopy/sections.c	Fri Mar  4 18:28:19 2016	(r296391)
@@ -1522,6 +1522,9 @@ add_gnu_debuglink(struct elfcopy *ecp)
 		err(EXIT_FAILURE, "strdup failed");
 	if (stat(ecp->debuglink, &sb) == -1)
 		err(EXIT_FAILURE, "stat failed");
+	if (sb.st_size == 0)
+		errx(EXIT_FAILURE, "empty debug link target %s",
+		    ecp->debuglink);
 	if ((buf = malloc(sb.st_size)) == NULL)
 		err(EXIT_FAILURE, "malloc failed");
 	if ((fp = fopen(ecp->debuglink, "r")) == NULL)



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