config.c: guard config parser from value=NULL
user.{name,email}, core.{pager,editor,excludesfile,whitespace} and i18n.{commit,logoutput}encoding all expect string values. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Feb 11, 2008 at 13:10 UTC
6c47d0e8f3983cff5bf633cb8e6f7ecfecf48db7
1 file changed
+15
-1
config.c
+15
-1
@@ -408,21 +408,29 @@ int git_default_config(const char *var, const char *value)
408
}
409
410
if (!strcmp(var, "user.name")) {
411
+ if (!value)
412
+ return config_error_nonbool(var);
413
strlcpy(git_default_name, value, sizeof(git_default_name));
414
return 0;
415
}
416
417
if (!strcmp(var, "user.email")) {
418
+ if (!value)
419
+ return config_error_nonbool(var);
420
strlcpy(git_default_email, value, sizeof(git_default_email));
421
return 0;
422
}
423
424
if (!strcmp(var, "i18n.commitencoding")) {
425
+ if (!value)
426
+ return config_error_nonbool(var);
427
git_commit_encoding = xstrdup(value);
428
return 0;
429
}
430
431
if (!strcmp(var, "i18n.logoutputencoding")) {
432
+ if (!value)
433
+ return config_error_nonbool(var);
434
git_log_output_encoding = xstrdup(value);
435
return 0;
436
}
@@ -434,23 +442,29 @@ int git_default_config(const char *var, const char *value)
442
}
443
444
if (!strcmp(var, "core.pager")) {
445
+ if (!value)
446
+ return config_error_nonbool(var);
447
pager_program = xstrdup(value);
448
return 0;
449
}
450
451
if (!strcmp(var, "core.editor")) {
452
+ if (!value)
453
+ return config_error_nonbool(var);
454
editor_program = xstrdup(value);
455
return 0;
456
}
457
458
if (!strcmp(var, "core.excludesfile")) {
459
if (!value)
448
- die("core.excludesfile without value");
460
+ return config_error_nonbool(var);
461
excludes_file = xstrdup(value);
462
return 0;
463
}
464
465
if (!strcmp(var, "core.whitespace")) {
466
+ if (!value)
467
+ return config_error_nonbool(var);
468
whitespace_rule_cfg = parse_whitespace_rule(value);
469
return 0;
470
}