summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-05-22 05:45:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-05-22 19:50:29 (GMT)
commitc9b4e9e5b6587ea433cd93c3c99f8720ff2fdad2 (patch)
tree765e982ecaa7bbba8886d1a020cc7cf3118f4349 /builtin/checkout.c
parent4b340cfab9c7a18e39bc531d6a6ffaffdf95f62d (diff)
downloadgit-c9b4e9e5b6587ea433cd93c3c99f8720ff2fdad2.zip
git-c9b4e9e5b6587ea433cd93c3c99f8720ff2fdad2.tar.gz
git-c9b4e9e5b6587ea433cd93c3c99f8720ff2fdad2.tar.bz2
pretty: avoid buffer overflow in format_person_part
When we parse the name and email from a commit to pretty-print them, we usually can just put the result directly into our strbuf result. However, if we are going to use the mailmap, then we must first copy them into a NUL-terminated buffer to feed to the mailmap machinery. We did so by using strlcpy into a static buffer, but we used it wrong. We fed it the length of the substring we wanted to copy, but never checked that that length was less than the size of the destination buffer. The simplest fix is to just use snprintf to copy the substring properly while still respecting the destination buffer's size. It might seem like replacing the static buffer with a strbuf would help, but we need to feed a static buffer to the mailmap machinery anyway, so there's not much benefit to handling arbitrary sizes. A more ideal solution would be for mailmap to grow an interface that: 1. Takes a pointer and length combination, instead of assuming a NUL-terminated string. 2. Returns a pointer to the mailmap's allocated string, rather than copying it into the buffer. Then we could avoid the need for an extra buffer entirely. However, doing this would involve a lot of refactoring of mailmap and of string_list (which mailmap uses to store the map itself). For now, let's do the simplest thing to fix the bug. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
0 files changed, 0 insertions, 0 deletions