summaryrefslogtreecommitdiff
path: root/fetch-pack.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2018-08-22 20:44:38 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-08-23 10:08:51 -0700
commit0d2db00e24ee2df4459151c5ba6de9306e30e727 (patch)
tree259ec0db3f8618b12743511fa26875b0dfa72c42 /fetch-pack.c
parentGit 2.18 (diff)
downloadtgif-0d2db00e24ee2df4459151c5ba6de9306e30e727.tar.xz
trailer: use size_t for string offsets
Many of the string-parsing functions inside trailer.c return integer offsets into the string (e.g., to point to the end of the trailer block). Several of these use an "int" to return or store the offsets. On a system where "size_t" is much larger than "int" (e.g., most 64-bit ones), it's easy to feed a gigantic commit message that results in a negative offset. This can result in us reading memory before the string (if the int is used as an index) or far after (if it's implicitly cast to a size_t by passing to a strbuf function). Let's fix this by using size_t for all string offsets. Note that several of the functions need ssize_t, since they use "-1" as a sentinel value. The interactions here can be pretty subtle. E.g., end_of_title in find_trailer_start() does not itself need to be signed, but it is compared to the result of last_line(), which is. That promotes the latter to unsigned, and the ">=" does not behave as you might expect. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-pack.c')
0 files changed, 0 insertions, 0 deletions