summaryrefslogtreecommitdiff
path: root/src/commit.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-05-02 16:24:14 +0200
committerPatrick Steinhardt <ps@pks.im>2016-05-02 17:45:24 +0200
commit7f407710ef5d46b18ee68f7f6580e593ee486bb4 (patch)
tree0d0b6dac6d392e8d50f14b53deccc5fc8bc67a72 /src/commit.c
parent7b24c4fd48abc67792f2af82c0eb374618475d17 (diff)
downloadlibgit2-7f407710ef5d46b18ee68f7f6580e593ee486bb4.tar.gz
odb_loose: fix undefined behavior when computing size
An object's size is computed by reading the object header's size field until the most significant bit is not set anymore. To get the total size, we increase the shift on each iteration and add the shifted value to the total size. We read the current value into a variable of type `unsigned char`, from which we then take all bits except the most significant bit and shift the result. We will end up with a maximum shift of 60, but this exceeds the width of the value's type, resulting in undefined behavior. Fix the issue by instead reading the values into a variable of type `unsigned long`, which matches the required width. This is equivalent to git.git, which uses an `unsigned long` as well.
Diffstat (limited to 'src/commit.c')
0 files changed, 0 insertions, 0 deletions