Re: Solaris test failure -- FAIL 61: invalid bool (set)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 19, 2008 at 06:17:42PM -0500, Whit Armstrong wrote:

>         git config --bool bool.nobool foobar
> t1300-repo-config.sh: line -176: 18181 Segmentation Fault      (core
> dumped) git config --bool bool.nobool foobar

Ah. The problem is that we use git_config_int() to parse the command
line option which, upon failure, attempts to print a message with
config_file_name, which is NULL (since we're not parsing a config file
currently). On most systems, printf simply prints "(null)", but on
Solaris, it segfaults. But we shouldn't be passing NULL anyway on any
system, since it makes the message ugly.

This patch fixes it.

-- >8 --
git_config_*: don't assume we are parsing a config file

These functions get called by other code, including parsing config
options from the command line. In that case, config_file_name is NULL,
leading to an ugly message or even a segfault on some implementations of
printf.

---
diff --git a/config.c b/config.c
index 8064cae..c105c13 100644
--- a/config.c
+++ b/config.c
@@ -280,11 +280,18 @@ int git_parse_ulong(const char *value, unsigned long *ret)
 	return 0;
 }
 
+static void die_bad_config(const char *name)
+{
+	if (config_file_name)
+		die("bad config value '%s' in %s", name, config_file_name);
+	die("bad config value for '%s'", name);
+}
+
 int git_config_int(const char *name, const char *value)
 {
 	long ret;
 	if (!git_parse_long(value, &ret))
-		die("bad config value for '%s' in %s", name, config_file_name);
+		die_bad_config(name);
 	return ret;
 }
 
@@ -292,7 +299,7 @@ unsigned long git_config_ulong(const char *name, const char *value)
 {
 	unsigned long ret;
 	if (!git_parse_ulong(value, &ret))
-		die("bad config value for '%s' in %s", name, config_file_name);
+		die_bad_config(name);
 	return ret;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux