Merge branch 'master' into next
[gitweb.git] / cache-tree.c
index a10902fd3050356529b26af7257de9eb2ab1623d..e452238ba7db47c08bd732dd425cb3be4c8bd73d 100644 (file)
@@ -341,7 +341,7 @@ static int update_one(struct cache_tree *it,
        }
 
        if (dryrun) {
-               char hdr[200];
+               unsigned char hdr[200];
                int hdrlen;
                write_sha1_file_prepare(buffer, offset, tree_type, it->sha1,
                                        hdr, &hdrlen);
@@ -440,6 +440,8 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
 {
        const char *buf = *buffer;
        unsigned long size = *size_p;
+       const char *cp;
+       char *ep;
        struct cache_tree *it;
        int i, subtree_nr;
 
@@ -453,7 +455,14 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
                goto free_return;
        buf++; size--;
        it = cache_tree();
-       if (sscanf(buf, "%d %d\n", &it->entry_count, &subtree_nr) != 2)
+
+       cp = buf;
+       it->entry_count = strtol(cp, &ep, 10);
+       if (cp == ep)
+               goto free_return;
+       cp = ep;
+       subtree_nr = strtol(cp, &ep, 10);
+       if (cp == ep)
                goto free_return;
        while (size && *buf && *buf != '\n') {
                size--;