Skip to content

Commit

Permalink
Fix potential heap buffer overflow in hdfs.c. Contributed by Igor Che…
Browse files Browse the repository at this point in the history
…rvatyuk.

(cherry picked from commit 4972e7a)
  • Loading branch information
aajisaka committed Aug 7, 2021
1 parent b98a8d2 commit 78c5fdd
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -945,9 +945,14 @@ struct hdfsStreamBuilder {
struct hdfsStreamBuilder *hdfsStreamBuilderAlloc(hdfsFS fs,
const char *path, int flags)
{
int path_len = strlen(path);
size_t path_len = strlen(path);
struct hdfsStreamBuilder *bld;

// Check for overflow in path_len
if (path_len > SIZE_MAX - sizeof(struct hdfsStreamBuilder)) {
errno = EOVERFLOW;
return NULL;
}
// sizeof(hdfsStreamBuilder->path) includes one byte for the string
// terminator
bld = malloc(sizeof(struct hdfsStreamBuilder) + path_len);
Expand Down

0 comments on commit 78c5fdd

Please sign in to comment.