]> gitweb.ps.run Git - ps-cgit/commitdiff
Fix out-of-bounds memory accesses with virtual_root=""
authorJohn Keeping <john@keeping.me.uk>
Mon, 1 Apr 2013 18:03:34 +0000 (19:03 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 8 Apr 2013 13:59:46 +0000 (15:59 +0200)
The CGit configuration variable virtual_root is normalized so that it
does not have a trailing '/' character, but it is allowed to be empty
(the empty string and NULL have different meanings here) and there is
code that is insufficiently cautious when checking if it ends in a '/':

if (virtual_root[strlen(virtual_root) - 1] != '/')

Clearly this check is redundant, but rather than simply removing it we
get a slight efficiency improvement by switching the normalization so
that the virtual_root variable always ends in '/'.  Do this with a new
"ensure_end" helper.

Signed-off-by: John Keeping <john@keeping.me.uk>

No differences found