diff options
| author | Petr Machata <[email protected]> | 2014-09-10 22:25:35 +0200 |
|---|---|---|
| committer | Petr Machata <[email protected]> | 2014-09-11 19:45:11 +0200 |
| commit | 237188e4d764598300a577e08fd872339812fb2c (patch) | |
| tree | f3b76afe694593cb4eb76fd8235554cfa24fdeef /libelf/elf_begin.c | |
| parent | 0375056af003d7676fb852e09782a985f3a52b1a (diff) | |
elf_begin sets elf_errno for cases that the file is completely unreadable
- The problem this is trying to solve can be seen for example thus:
$ eu-readelf -a /
eu-readelf: failed reading '/': (null)
With the fix we see a proper error number and get a reasonable error
message:
$ eu-readelf -a /
eu-readelf: failed reading '/': invalid file descriptor
Signed-off-by: Petr Machata <[email protected]>
Diffstat (limited to 'libelf/elf_begin.c')
| -rw-r--r-- | libelf/elf_begin.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c index 1ef70ac3..c3ad1406 100644 --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -550,9 +550,12 @@ read_unmmaped_file (int fildes, off_t offset, size_t maxsize, Elf_Cmd cmd, maxsize), offset); if (unlikely (nread == -1)) - /* We cannot even read the head of the file. Maybe FILDES is associated - with an unseekable device. This is nothing we can handle. */ - return NULL; + { + /* We cannot even read the head of the file. Maybe FILDES is associated + with an unseekable device. This is nothing we can handle. */ + __libelf_seterrno (ELF_E_INVALID_FILE); + return NULL; + } /* See what kind of object we have here. */ Elf_Kind kind = determine_kind (mem.header, nread); |
