Merge branch 'es/want-color-fd-defensive'
Futureproofing a helper function that can easily be misused. * es/want-color-fd-defensive: color: protect against out-of-bounds reads and writes
This commit is contained in:
commit
271940c11c
3
color.c
3
color.c
@ -343,6 +343,9 @@ int want_color_fd(int fd, int var)
|
|||||||
|
|
||||||
static int want_auto[3] = { -1, -1, -1 };
|
static int want_auto[3] = { -1, -1, -1 };
|
||||||
|
|
||||||
|
if (fd < 1 || fd >= ARRAY_SIZE(want_auto))
|
||||||
|
BUG("file descriptor out of range: %d", fd);
|
||||||
|
|
||||||
if (var < 0)
|
if (var < 0)
|
||||||
var = git_use_color_default;
|
var = git_use_color_default;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user