diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-03-19 23:25:37 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-03-19 23:25:37 +0100 |
commit | 8779c141da62d66be5d420b94d506636006a7901 (patch) | |
tree | 5c9eaf883c268946b84535df55ffd3a4fe11f3eb /fsmonitor.c | |
parent | Merge branch 'jc/calloc-fix' (diff) | |
parent | fsmonitor: avoid global-buffer-overflow READ when checking trivial response (diff) | |
download | git-8779c141da62d66be5d420b94d506636006a7901.tar.xz git-8779c141da62d66be5d420b94d506636006a7901.zip |
Merge branch 'jh/fsmonitor-prework'
The fsmonitor interface read from its input without making sure
there is something to read from. This bug is new in 2.31
timeframe.
* jh/fsmonitor-prework:
fsmonitor: avoid global-buffer-overflow READ when checking trivial response
Diffstat (limited to 'fsmonitor.c')
-rw-r--r-- | fsmonitor.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fsmonitor.c b/fsmonitor.c index 23f8a0c97e..ab9bfc60b3 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -185,10 +185,10 @@ static int query_fsmonitor(int version, const char *last_update, struct strbuf * int fsmonitor_is_trivial_response(const struct strbuf *query_result) { static char trivial_response[3] = { '\0', '/', '\0' }; - int is_trivial = !memcmp(trivial_response, - &query_result->buf[query_result->len - 3], 3); - return is_trivial; + return query_result->len >= 3 && + !memcmp(trivial_response, + &query_result->buf[query_result->len - 3], 3); } static void fsmonitor_refresh_callback(struct index_state *istate, char *name) |