tree-diff: catch integer overflow in combine_diff_path allocation
commitd770187872e8408a8e4c0533cf6e6913776882b0
authorJeff King <peff@peff.net>
Fri, 19 Feb 2016 11:21:30 +0000 (19 06:21 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Mar 2016 17:41:02 +0000 (16 10:41 -0700)
tree34d686142d5a3c7136a6f9bc6571583d7d8e124c
parent935de81289cd04b4736c538747c53df123c30d1c
tree-diff: catch integer overflow in combine_diff_path allocation

A combine_diff_path struct has two "flex" members allocated
alongside the struct: a string to hold the pathname, and an
array of parent pointers. We use an "int" to compute this,
meaning we may easily overflow it if the pathname is
extremely long.

We can fix this by using size_t, and checking for overflow
with the st_add helper.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.h
tree-diff.c