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
This commit is contained in:
Ed Maste 2017-04-24 14:51:53 +00:00
parent d0cfe1010e
commit fa903e5725
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=317371

View File

@ -1285,8 +1285,9 @@ parse_symlist_file(struct elfcopy *ecp, const char *fn, unsigned int op)
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';