X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=fast-import.c;h=6faaaacb68999db294d20ecbb30772223bfc1b57;hb=7da4e2280ccaf5ecb357f7cb2b81d62f78f00f9e;hp=a2a24588a99957d5af759ca6d8858366430ab3a3;hpb=50a991ec46d57ffc4b7fbd0e8a13182dab3cd5de;p=git.git diff --git a/fast-import.c b/fast-import.c index a2a24588a..6faaaacb6 100644 --- a/fast-import.c +++ b/fast-import.c @@ -905,10 +905,10 @@ static char *keep_pack(char *curr_index_name) keep_fd = odb_pack_keep(name, sizeof(name), pack_data->sha1); if (keep_fd < 0) - die("cannot create keep file"); + die_errno("cannot create keep file"); write_or_die(keep_fd, keep_msg, strlen(keep_msg)); if (close(keep_fd)) - die("failed to write keep file"); + die_errno("failed to write keep file"); snprintf(name, sizeof(name), "%s/pack/pack-%s.pack", get_object_directory(), sha1_to_hex(pack_data->sha1)); @@ -1744,10 +1744,12 @@ static int validate_raw_date(const char *src, char *result, int maxlen) { const char *orig_src = src; char *endp; + unsigned long num; errno = 0; - strtoul(src, &endp, 10); + num = strtoul(src, &endp, 10); + /* NEEDSWORK: perhaps check for reasonable values? */ if (errno || endp == src || *endp != ' ') return -1; @@ -1755,8 +1757,9 @@ static int validate_raw_date(const char *src, char *result, int maxlen) if (*src != '-' && *src != '+') return -1; - strtoul(src + 1, &endp, 10); - if (errno || endp == src || *endp || (endp - orig_src) >= maxlen) + num = strtoul(src + 1, &endp, 10); + if (errno || endp == src + 1 || *endp || (endp - orig_src) >= maxlen || + 1400 < num) return -1; strcpy(result, orig_src); @@ -2342,7 +2345,7 @@ static void import_marks(const char *input_file) char line[512]; FILE *f = fopen(input_file, "r"); if (!f) - die("cannot read %s: %s", input_file, strerror(errno)); + die_errno("cannot read '%s'", input_file); while (fgets(line, sizeof(line), f)) { uintmax_t mark; char *end; @@ -2448,7 +2451,7 @@ int main(int argc, const char **argv) fclose(pack_edges); pack_edges = fopen(a + 20, "a"); if (!pack_edges) - die("Cannot open %s: %s", a + 20, strerror(errno)); + die_errno("Cannot open '%s'", a + 20); } else if (!strcmp(a, "--force")) force_update = 1; else if (!strcmp(a, "--quiet"))