commit - 8da9e5f4a4b7b369d617fdceb6e9b715f8d6d121
commit + 27793341b019f82d415b7a38f106a5424a3d2ecb
blob - 34bd324b68b53131fb06adc2a13b17f6a601bc78
blob + 798180a9e9eb5eb4fab5229324c634c309f2baca
--- include/got_error.h
+++ include/got_error.h
#define GOT_ERR_FILEIDX_CSUM 53
#define GOT_ERR_PATH_PREFIX 54
#define GOT_ERR_ANCESTRY 55
+#define GOT_ERR_FILEIDX_BAD 56
static const struct got_error {
int code;
"different path prefix" },
{ GOT_ERR_ANCESTRY, "specified commit does not share ancestry with "
"the current branch" },
+ { GOT_ERR_FILEIDX_BAD, "file index is corrupt" },
};
/*
blob - dd1d1db9598a09e3df467644273c623ca483d674
blob + b3b7b356254d4d7892f5ebfce76f811fbccf2813
--- lib/fileindex.c
+++ lib/fileindex.c
n = fread(val, 1, sizeof(*val), infile);
if (n != sizeof(*val))
- return got_ferror(infile, GOT_ERR_IO);
+ return got_ferror(infile, GOT_ERR_FILEIDX_BAD);
SHA1Update(ctx, (uint8_t *)val, sizeof(*val));
*val = be64toh(*val);
return NULL;
n = fread(val, 1, sizeof(*val), infile);
if (n != sizeof(*val))
- return got_ferror(infile, GOT_ERR_IO);
+ return got_ferror(infile, GOT_ERR_FILEIDX_BAD);
SHA1Update(ctx, (uint8_t *)val, sizeof(*val));
*val = be32toh(*val);
return NULL;
n = fread(val, 1, sizeof(*val), infile);
if (n != sizeof(*val))
- return got_ferror(infile, GOT_ERR_IO);
+ return got_ferror(infile, GOT_ERR_FILEIDX_BAD);
SHA1Update(ctx, (uint8_t *)val, sizeof(*val));
*val = be16toh(*val);
return NULL;
do {
n = fread(buf, 1, sizeof(buf), infile);
if (n != sizeof(buf))
- return got_ferror(infile, GOT_ERR_IO);
+ return got_ferror(infile, GOT_ERR_FILEIDX_BAD);
if (len + sizeof(buf) > totlen) {
char *p = reallocarray(*path, totlen + sizeof(buf), 1);
if (p == NULL) {
n = fread(entry->blob_sha1, 1, SHA1_DIGEST_LENGTH, infile);
if (n != SHA1_DIGEST_LENGTH) {
- err = got_ferror(infile, GOT_ERR_IO);
+ err = got_ferror(infile, GOT_ERR_FILEIDX_BAD);
goto done;
}
SHA1Update(ctx, entry->blob_sha1, SHA1_DIGEST_LENGTH);
n = fread(entry->commit_sha1, 1, SHA1_DIGEST_LENGTH, infile);
if (n != SHA1_DIGEST_LENGTH) {
- err = got_ferror(infile, GOT_ERR_IO);
+ err = got_ferror(infile, GOT_ERR_FILEIDX_BAD);
goto done;
}
SHA1Update(ctx, entry->commit_sha1, SHA1_DIGEST_LENGTH);
if (n != len) {
if (n == 0) /* EOF */
return NULL;
- return got_ferror(infile, GOT_ERR_IO);
+ return got_ferror(infile, GOT_ERR_FILEIDX_BAD);
}
SHA1Update(&ctx, buf, len);
n = fread(sha1_expected, 1, sizeof(sha1_expected), infile);
if (n != sizeof(sha1_expected))
- return got_ferror(infile, GOT_ERR_IO);
+ return got_ferror(infile, GOT_ERR_FILEIDX_BAD);
SHA1Final(sha1, &ctx);
if (memcmp(sha1, sha1_expected, SHA1_DIGEST_LENGTH) != 0)
return got_error(GOT_ERR_FILEIDX_CSUM);