summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorLibravatar René Scharfe <l.s.r@web.de>2019-06-22 12:03:30 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-06-24 12:34:17 -0700
commit3fb72c7b4d90fb7f95ca60f448c7739cca6c1846 (patch)
tree1119db7f844b01e7fca60876a7ad97a61a89e7b3 /Documentation
parentconfig: avoid calling `labs()` on too-large data type (diff)
downloadtgif-3fb72c7b4d90fb7f95ca60f448c7739cca6c1846.tar.xz
config: use unsigned_mult_overflows to check for overflows
parse_unit_factor() checks if a K, M or G is present after a number and multiplies it by 2^10, 2^20 or 2^30, respectively. One of its callers checks if the result is smaller than the number alone to detect overflows. The other one passes 1 as the number and does multiplication and overflow check itself in a similar manner. This works, but is inconsistent, and it would break if we added support for a bigger unit factor. E.g. 16777217T is 2^64 + 2^40, i.e. too big for a 64-bit number. Modulo 2^64 we get 2^40 == 1TB, which is bigger than the raw number 16777217 == 2^24 + 1, so the overflow would go undetected by that method. Let both callers pass 1 and handle overflow check and multiplication themselves. Do the check before the multiplication, using unsigned_mult_overflows, which is simpler and can deal with larger unit factors. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation')
0 files changed, 0 insertions, 0 deletions