From: Jeff King Date: Tue, 14 Feb 2017 17:27:45 +0000 (-0500) Subject: show-branch: store resolved head in heap buffer X-Git-Tag: v2.12.2~14^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d9e557a320bd4695bccad873e176562489b2d199?hp=d9e557a320bd4695bccad873e176562489b2d199 show-branch: store resolved head in heap buffer We resolve HEAD and copy the result to a fixed-size buffer with memcpy, never checking that it actually fits. This bug dates back to 8098a178b (Add git-symbolic-ref, 2005-09-30). Before that we used readlink(), which took a maximum buffer size. We can fix this by using resolve_refdup(), which duplicates the buffer on the heap. That also lets us just check for a NULL pointer to see if we have resolved HEAD, and drop the extra head_p variable. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano ---