@matheusbsbs / matheus-bagliano / commits / 7e5dcea831
Fork 0

fast-import pull request

* skip_optional_lf() decl is old-style -- please say static skip_optional_lf(void) { ... } * t9300 #14 fails, like this: * expecting failure: git-fast-import <input fatal: Branch name doesn't conform to GIT standards: .badbranchname fast-import: dumping crash report to .git/fast_import_crash_14354 ./test-lib.sh: line 143: 14354 Segmentation fault git-fast-import <input -- >8 -- Subject: [PATCH] fastimport: Fix re-use of va_list The va_list is designed to be used only once. The current code reuses va_list argument may cause segmentation fault. Copy and release the arguments to avoid this problem. While we are at it, fix old-style function declaration of skip_optional_lf(). Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Junio C Hamano committed Aug 19, 2007 at 02:50 UTC 7e5dcea8311472156ed0fea164e689777353f931
1 file changed +5 -3
fast-import.c
+5 -3
@@ -442,16 +442,18 @@ static void write_crash_report(const char *err, va_list params)
442 static NORETURN void die_nicely(const char *err, va_list params)
443 {
444 static int zombie;
445 + va_list x_params;
446
447 + va_copy(x_params, params);
448 fputs("fatal: ", stderr);
449 vfprintf(stderr, err, params);
450 fputc('\n', stderr);
451
452 if (!zombie) {
453 zombie = 1;
452 - write_crash_report(err, params);
454 + write_crash_report(err, x_params);
455 }
454 -
456 + va_end(x_params);
457 exit(128);
458 }
459
@@ -1618,7 +1620,7 @@ static void read_next_command(void)
1620 } while (command_buf.buf[0] == '#');
1621 }
1622
1621 -static void skip_optional_lf()
1623 +static void skip_optional_lf(void)
1624 {
1625 int term_char = fgetc(stdin);
1626 if (term_char != '\n' && term_char != EOF)