diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-07-03 00:25:23 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-03 00:34:59 -0700 |
commit | 6991357513bf8bfbb71a4675e271b386cc273476 (patch) | |
tree | 3369267f2ff1b0da1c9a63768fdd1aa7da49167b /builtin-fast-export.c | |
parent | 6cbf8b00fb27f5f55f1a5645ba60c451cb090fc1 (diff) | |
download | git-6991357513bf8bfbb71a4675e271b386cc273476.tar.gz |
fast-export --export-marks: fix off by one error
The export_marks() function iterated over a (potentially sparsely
populated) hashtable, but it accessed it starting from offset 1 and one
element beyond the end.
Noticed by SungHyun Nam.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-fast-export.c')
-rw-r--r-- | builtin-fast-export.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 45786ef1b7..170b82e6ef 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -379,19 +379,19 @@ static void export_marks(char *file) if (!f) error("Unable to open marks file %s for writing", file); - for (i = 0; i < idnums.size; ++i) { - deco++; - if (deco && deco->base && deco->base->type == 1) { + for (i = 0; i < idnums.size; i++) { + if (deco->base && deco->base->type == 1) { mark = ptr_to_mark(deco->decoration); fprintf(f, ":%u %s\n", mark, sha1_to_hex(deco->base->sha1)); } + deco++; } if (ferror(f) || fclose(f)) error("Unable to write marks file %s.", file); } -static void import_marks(char * input_file) +static void import_marks(char *input_file) { char line[512]; FILE *f = fopen(input_file, "r"); @@ -407,7 +407,7 @@ static void import_marks(char * input_file) line_end = strchr(line, '\n'); if (line[0] != ':' || !line_end) die("corrupt mark line: %s", line); - *line_end = 0; + *line_end = '\0'; mark = strtoumax(line + 1, &mark_end, 10); if (!mark || mark_end == line + 1 |