Commit c146374c by Patrick Steinhardt

revparse: detect out-of-memory cases when parsing curly brace contents

When extracting curly braces (e.g. the "upstream" part in
"HEAD@{upstream}"), we put the curly braces' contents into a `git_buf`
structure, but don't check the return value of `git_buf_putc`. So when
we run out-of-memory, we'll use a partially filled buffer without
noticing.

Let's fix this issue by checking `git_buf_putc`'s return value.
parent c708e5e5
...@@ -537,7 +537,8 @@ static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t * ...@@ -537,7 +537,8 @@ static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t *
if (spec[*pos] == '\0') if (spec[*pos] == '\0')
return GIT_EINVALIDSPEC; return GIT_EINVALIDSPEC;
git_buf_putc(buf, spec[(*pos)++]); if (git_buf_putc(buf, spec[(*pos)++]) < 0)
return -1;
} }
(*pos)++; (*pos)++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment