From: Jeff King Date: Thu, 19 Jun 2014 21:30:26 +0000 (-0400) Subject: unique_path: fix unlikely heap overflow X-Git-Tag: v2.1.0-rc0~63^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/45bc131dd3e1eb6edd903957cf9d42f37ad02181?ds=inline;hp=45bc131dd3e1eb6edd903957cf9d42f37ad02181 unique_path: fix unlikely heap overflow When merge-recursive creates a unique filename, it uses a template like: path~branch_%d where the final "_%d" is filled by an incrementing counter until we find a unique name. We allocate 8 characters for the counter, but there is no logic to limit the size of the integer. Of course, this is extremely unlikely, as you would need a hundred million collisions to trigger the problem. Even if an attacker constructed a specialized repo, it is unlikely that the victim would have the patience to run the merge. However, we can make it trivially correct (and hopefully more readable) by using a strbuf. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano ---