reflog_expire_cfg: NUL-terminate pattern field
authorJeff King <peff@peff.net>
Fri, 19 Feb 2016 11:21:08 +0000 (06:21 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Feb 2016 17:40:37 +0000 (09:40 -0800)
commitc3a700fba1693f68643f24c4f2e6d4cdd240babf
treeb14585b2a3c505d6ee2aadd2dac2eaf338680def
parenta08595f76159b09d57553e37a5123f1091bb13e7
reflog_expire_cfg: NUL-terminate pattern field

You can tweak the reflog expiration for a particular subset
of refs by configuring gc.foo.reflogexpire. We keep a linked
list of reflog_expire_cfg structs, each of which holds the
pattern and a "len" field for the length of the pattern. The
pattern itself is _not_ NUL-terminated.

However, we feed the pattern directly to wildmatch(), which
expects a NUL-terminated string, meaning it may keep reading
random junk after our struct.

We can fix this by allocating an extra byte for the NUL
(which is already zero because we use xcalloc). Let's also
drop the misleading "len" field, which is no longer
necessary. The existing use of "len" can be converted to use
strncmp().

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/reflog.c