From: Alan Modra Date: Thu, 20 Jan 2005 06:46:41 +0000 (+0000) Subject: PR gas/684 X-Git-Tag: gdb-pre-i18n-errorwarning-20050211~239 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c556cc9c6d052eef25dbb030a297cc0e204ba5c7;p=thirdparty%2Fbinutils-gdb.git PR gas/684 * read.c (s_incbin): Adjust default count for skip. Check validity of count and skip rigorously. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 41b654cea57..572d8e00c3b 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2005-01-20 Alan Modra + + PR gas/684 + * read.c (s_incbin): Adjust default count for skip. Check validity + of count and skip rigorously. + 2005-01-19 Fred Fish * config/tc-mips.c (dummy_opcode): Add init for new struct member. diff --git a/gas/read.c b/gas/read.c index e04e00c865f..daea0f9a071 100644 --- a/gas/read.c +++ b/gas/read.c @@ -5000,13 +5000,13 @@ s_incbin (int x ATTRIBUTE_UNUSED) } file_len = ftell (binfile); - /* If a count was not specified use the size of the file. */ + /* If a count was not specified use the remainder of the file. */ if (count == 0) - count = file_len; + count = file_len - skip; - if (skip + count > file_len) + if (skip < 0 || count < 0 || file_len < 0 || skip + count > file_len) { - as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"), + as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"), skip, count, file_len); goto done; }