Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance error log with file path for map_file() #921

Merged
merged 1 commit into from
Apr 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,19 +1302,19 @@ static int map_file(mapped_file_t* mf, const char* path) {
}

if (fstat(fd, &st) == -1) {
fprintf(stderr, "fstat() == -1\n");
fprintf(stderr, "fstat(%s) == -1\n", path);
goto on_error;
}
if (sizeof(st.st_size) != sizeof(size_t)) {
/* On 32 bit systems, check if there is an overflow */
if (st.st_size > (off_t)UINT32_MAX) {
fprintf(stderr, "mmap() size_t overflow\n");
fprintf(stderr, "mmap() size_t overflow for file %s\n", path);
goto on_error;
}
}
mf->base = (uint8_t*) mmap(NULL, (size_t)(st.st_size), PROT_READ, MAP_SHARED, fd, 0);
if (mf->base == MAP_FAILED) {
fprintf(stderr, "mmap() == MAP_FAILED\n");
fprintf(stderr, "mmap() == MAP_FAILED for file %s\n", path);
goto on_error;
}

Expand Down