summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-02-23 11:23:26 +0100
committerPatrick Steinhardt <ps@pks.im>2016-02-23 12:07:14 +0100
commit0f1e2d2066115e62fd7396e0f436b4a5dd8384cd (patch)
tree1a1bd1bb3a67d671d135d7f3b7a74e73a3ec2e92 /include/git2
parent7808c93797b3fa9f552bd2e24672089b8d27ad2a (diff)
downloadlibgit2-0f1e2d2066115e62fd7396e0f436b4a5dd8384cd.tar.gz
index: fix contradicting comparison
The overflow check in `read_reuc` tries to verify if the `git__strtol32` parses an integer bigger than UINT_MAX. The `tmp` variable is casted to an unsigned int for this and then checked for being greater than UINT_MAX, which obviously can never be true. Fix this by instead fixing the `mode` field's size in `struct git_index_reuc_entry` to `uint32_t`. We can now parse the int with `git__strtol64`, which can never return a value bigger than `UINT32_MAX`, and additionally checking if the returned value is smaller than zero. We do not need to handle overflows explicitly here, as `git__strtol64` returns an error when the returned value would overflow.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/sys/index.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/git2/sys/index.h b/include/git2/sys/index.h
index 29a99f798..2e2b87e68 100644
--- a/include/git2/sys/index.h
+++ b/include/git2/sys/index.h
@@ -25,7 +25,7 @@ typedef struct git_index_name_entry {
/** Representation of a resolve undo entry in the index. */
typedef struct git_index_reuc_entry {
- unsigned int mode[3];
+ uint32_t mode[3];
git_oid oid[3];
char *path;
} git_index_reuc_entry;