Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-03-20 01:25:37 +0300
committerJunio C Hamano <gitster@pobox.com>2021-03-20 01:25:37 +0300
commit8779c141da62d66be5d420b94d506636006a7901 (patch)
tree5c9eaf883c268946b84535df55ffd3a4fe11f3eb /fsmonitor.c
parenteabacfd9cb58f22ffbacf935bf03747a08640fc7 (diff)
parent097ea2c8486e9fc8c6c11bad8688434edeeda3f2 (diff)
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.c6
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)