diff options
Diffstat (limited to 'linker/linker.cpp')
-rw-r--r-- | linker/linker.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index ab0fc0762..b2911b8ce 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -814,12 +814,20 @@ static soinfo* load_library(LoadTaskList& load_tasks, const char* name, int rtld DL_ERR("file offset for the library \"%s\" is not page-aligned: %" PRId64, name, file_offset); return nullptr; } + if (file_offset < 0) { + DL_ERR("file offset for the library \"%s\" is negative: %" PRId64, name, file_offset); + return nullptr; + } struct stat file_stat; if (TEMP_FAILURE_RETRY(fstat(fd, &file_stat)) != 0) { DL_ERR("unable to stat file for the library \"%s\": %s", name, strerror(errno)); return nullptr; } + if (file_offset >= file_stat.st_size) { + DL_ERR("file offset for the library \"%s\" >= file size: %" PRId64 " >= %" PRId64, name, file_offset, file_stat.st_size); + return nullptr; + } // Check for symlink and other situations where // file can have different names. |