summaryrefslogtreecommitdiff
path: root/color.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2017-01-19 11:41:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-19 19:21:52 (GMT)
commitc2f41bf521b5b2ffb9ea93b98e4a57bf73d70864 (patch)
treebedd776e04764e7e7fef21813d429fe6981555cc /color.c
parent6ebdac1bab966b720d776aa43ca188fe378b1f4b (diff)
downloadgit-c2f41bf521b5b2ffb9ea93b98e4a57bf73d70864.zip
git-c2f41bf521b5b2ffb9ea93b98e4a57bf73d70864.tar.gz
git-c2f41bf521b5b2ffb9ea93b98e4a57bf73d70864.tar.bz2
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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'color.c')
-rw-r--r--color.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/color.c b/color.c
index 81c2676..a9eadd1 100644
--- a/color.c
+++ b/color.c
@@ -207,6 +207,9 @@ int color_parse_mem(const char *value, int value_len, char *dst)
struct color fg = { COLOR_UNSPECIFIED };
struct color bg = { COLOR_UNSPECIFIED };
+ if (!len)
+ return -1;
+
if (!strncasecmp(value, "reset", len)) {
xsnprintf(dst, end - dst, GIT_COLOR_RESET);
return 0;