summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-09-27 14:31:57 +0200
committerVicent Marti <tanoku@gmail.com>2011-09-27 14:33:19 +0200
commit8e9bfa4cf0584527cdbee0dba05cf5aabc60a4bc (patch)
tree1b347439bbf8ca019f0e421ea864090e75d81af8
parent9ef9e8c3ad014278fdec7ff6b0b6038584db8c20 (diff)
downloadlibgit2-8e9bfa4cf0584527cdbee0dba05cf5aabc60a4bc.tar.gz
tree: Fix check for valid attributes
-rw-r--r--src/tree.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tree.c b/src/tree.c
index 227da3c63..0acf74ede 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -15,7 +15,8 @@
#define MAX_FILEMODE 0777777
#define MAX_FILEMODE_BYTES 6
-static int valid_attributes(const int attributes) {
+static int valid_attributes(const int attributes)
+{
return attributes >= 0 && attributes <= MAX_FILEMODE;
}
@@ -169,8 +170,9 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
return GIT_ENOMEM;
if (git__strtol32(&tmp, buffer, &buffer, 8) < GIT_SUCCESS ||
- !buffer || tmp > UINT_MAX || tmp < 0)
+ !buffer || !valid_attributes(tmp))
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tree. Can't parse attributes");
+
entry->attr = tmp;
if (*buffer++ != ' ') {