diff options
author | Nick Clifton <nickc@redhat.com> | 2021-02-09 14:22:23 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2021-02-09 14:22:23 +0000 |
commit | 284beb431f44cf0b4b1567ebf9dfe44a24ccfe2e (patch) | |
tree | a1dfa0a789a75941c4c37cde324e779b37b5828e /gas/read.c | |
parent | 9b87f84a3513c852eca395e3aa47081ef2f12e60 (diff) | |
download | gdb-284beb431f44cf0b4b1567ebf9dfe44a24ccfe2e.zip gdb-284beb431f44cf0b4b1567ebf9dfe44a24ccfe2e.tar.gz gdb-284beb431f44cf0b4b1567ebf9dfe44a24ccfe2e.tar.bz2 |
Add a sanity check of files include by .incbin.
PR 27381
* read.c (s_incbin): Check that the file to be included is a
regular, non-directory file.
* testsuite/gas/all/pr27381.s: New test source file.
* testsuite/gas/all/pr27381.d: New test control file.
* testsuite/gas/all/pr27381.err: Expected error output for the new test.
* testsuite/gas/all/gas.exp: Run the new test.
Diffstat (limited to 'gas/read.c')
-rw-r--r-- | gas/read.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -5909,7 +5909,16 @@ s_incbin (int x ATTRIBUTE_UNUSED) if (binfile) { long file_len; + struct stat filestat; + if (fstat (fileno (binfile), &filestat) != 0 + || ! S_ISREG (filestat.st_mode) + || S_ISDIR (filestat.st_mode)) + { + as_bad (_("unable to include `%s'"), path); + goto done; + } + register_dependency (path); /* Compute the length of the file. */ |