Skip to content

Commit 8779c14

Browse files
committed
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
2 parents eabacfd + 097ea2c commit 8779c14

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fsmonitor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ static int query_fsmonitor(int version, const char *last_update, struct strbuf *
185185
int fsmonitor_is_trivial_response(const struct strbuf *query_result)
186186
{
187187
static char trivial_response[3] = { '\0', '/', '\0' };
188-
int is_trivial = !memcmp(trivial_response,
189-
&query_result->buf[query_result->len - 3], 3);
190188

191-
return is_trivial;
189+
return query_result->len >= 3 &&
190+
!memcmp(trivial_response,
191+
&query_result->buf[query_result->len - 3], 3);
192192
}
193193

194194
static void fsmonitor_refresh_callback(struct index_state *istate, char *name)

0 commit comments

Comments
 (0)