Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
color.c: fix color_parse_mem() with value_len == 0
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Thu, 19 Jan 2017 11:41:21 +0000
(18:41 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 19 Jan 2017 19:21:52 +0000
(11:21 -0800)
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>
color.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
6ebdac1
)
diff --git
a/color.c
b/color.c
index 81c26767239f9e028057c1843f57b77640db6c26..a9eadd190a8c44fe4e670112705478b5a8c8492d 100644
(file)
--- 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;