Skip to content

Commit c2f41bf

Browse files
pcloudsgitster
authored andcommitted
color.c: fix color_parse_mem() with value_len == 0
In this code we want to match the word "reset". If len is zero, strncasecmp() will return zero and we incorrectly assume it's "reset" as a result. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6ebdac1 commit c2f41bf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

color.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ int color_parse_mem(const char *value, int value_len, char *dst)
207207
struct color fg = { COLOR_UNSPECIFIED };
208208
struct color bg = { COLOR_UNSPECIFIED };
209209

210+
if (!len)
211+
return -1;
212+
210213
if (!strncasecmp(value, "reset", len)) {
211214
xsnprintf(dst, end - dst, GIT_COLOR_RESET);
212215
return 0;

0 commit comments

Comments
 (0)