X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=sha1_file.c;h=4304fe9bbc2b8e796e944fa7ddb2ea2791000adf;hb=40250af411f33afa0c39a5d461829b676453ce3b;hp=0897b945e5dace8189adc35e6eea389cfc7606af;hpb=2603fa5fb358ee7834bc9e1a2e391f69d8fce815;p=git.git diff --git a/sha1_file.c b/sha1_file.c index 0897b945e..4304fe9bb 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1532,15 +1532,14 @@ uint32_t num_packed_objects(const struct packed_git *p) return (uint32_t)((p->index_size - 20 - 20 - 4*256) / 24); } -int nth_packed_object_sha1(const struct packed_git *p, uint32_t n, - unsigned char* sha1) +const unsigned char *nth_packed_object_sha1(const struct packed_git *p, + uint32_t n) { const unsigned char *index = p->index_data; index += 4 * 256; if (num_packed_objects(p) <= n) - return -1; - hashcpy(sha1, index + 24 * n + 4); - return 0; + return NULL; + return index + 24 * n + 4; } off_t find_pack_entry_one(const unsigned char *sha1, @@ -2020,7 +2019,8 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha if (write_buffer(fd, compressed, size) < 0) die("unable to write sha1 file"); fchmod(fd, 0444); - close(fd); + if (close(fd)) + die("unable to write sha1 file"); free(compressed); return move_temp_to_file(tmpfile, filename); @@ -2155,7 +2155,8 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer, inflateEnd(&stream); fchmod(local, 0444); - close(local); + if (close(local) != 0) + die("unable to write sha1 file"); SHA1_Final(real_sha1, &c); if (ret != Z_STREAM_END) { unlink(tmpfile);