aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2016-03-04 18:28:19 +0000
committerEd Maste <emaste@FreeBSD.org>2016-03-04 18:28:19 +0000
commitf5e9c916afed4a948fe5c03bfaee038d165e12ab (patch)
treed7eb8aea42588c495df8c2fe3fc289cfd88f98c5 /contrib
parent8b66d3d3bd0a38e46fd98c74bb2c1eb8483c0bbd (diff)
downloadsrc-f5e9c916afed4a948fe5c03bfaee038d165e12ab.tar.gz
src-f5e9c916afed4a948fe5c03bfaee038d165e12ab.zip
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
Notes
Notes: svn path=/head/; revision=296391
Diffstat (limited to 'contrib')
-rw-r--r--contrib/elftoolchain/elfcopy/sections.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c
index 2ba3d48f87a8..5848eab7d3f7 100644
--- a/contrib/elftoolchain/elfcopy/sections.c
+++ b/contrib/elftoolchain/elfcopy/sections.c
@@ -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)