Repository navigation
renderd: fix partial-read, signal-handler and malloc-check bugs #503
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,11 @@ | |
| struct meta_layout *m = (struct meta_layout *)malloc(header_len); | ||
| size_t file_offset, tile_size; | ||
|
|
||
| if (m == NULL) { | ||
| snprintf(log_msg, PATH_MAX - 1, "Failed to allocate memory for metatile header\n"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive: the format string is a constant literal with no arguments, so nothing external can influence it, and |
||
| return -1; | ||
| } | ||
|
|
||
| meta_offset = xyzo_to_meta(path, sizeof(path), (char *)(store->storage_ctx), xmlconfig, options, x, y, z); | ||
|
|
||
| fd = open(path, O_RDONLY); | ||
|
|
@@ -219,6 +224,12 @@ | |
| g_logger(G_LOG_LEVEL_DEBUG, "Creating and writing a metatile to %s", meta_path); | ||
|
|
||
| tmp = (char *)malloc(sizeof(char) * strlen(meta_path) + 24); | ||
|
|
||
| if (tmp == NULL) { | ||
| g_logger(G_LOG_LEVEL_ERROR, "file_metatile_write: failed to allocate memory for temp path"); | ||
| return -1; | ||
| } | ||
|
|
||
| snprintf(tmp, strlen(meta_path) + 24, "%s.%lu", meta_path, (unsigned long) pthread_self()); | ||
|
|
||
| if (mkdirp(tmp)) { | ||
|
|
@@ -246,7 +257,14 @@ | |
| } | ||
|
|
||
| close(fd); | ||
| rename(tmp, meta_path); | ||
|
|
||
| if (rename(tmp, meta_path) != 0) { | ||
| g_logger(G_LOG_LEVEL_WARNING, "Error renaming temp file %s to %s: %s", tmp, meta_path, strerror(errno)); | ||
| unlink(tmp); | ||
| free(tmp); | ||
| return -1; | ||
| } | ||
|
|
||
| free(tmp); | ||
|
|
||
| return sz; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False positive: Flawfinder flags every
recv()call. This one reads into the fixed-sizestruct protocoland is bounded bysizeof(struct protocol) - ret_size, so it can't overrun, and the loop it replaces already calledrecv()on the same socket.