summaryrefslogtreecommitdiff
path: root/ipadm/debian/patches/ipmgmtd-segfault.patch
blob: 9bbab6a9e3e8c87f6a75b901b1c6b70c73ba3c3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Description: strcmp(NULL, NULL) returns 0 on i386,
 but crashes on amd64.
Dyson-Bug: http://osdyson.org/issues/105
Index: ipadm/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c
===================================================================
--- ipadm.orig/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c	2012-10-08 00:25:23.000000000 +0000
+++ ipadm/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c	2013-03-29 00:23:59.807522523 +0000
@@ -77,6 +77,19 @@
 /* signifies whether volatile copy of data store is in use */
 static boolean_t ipmgmt_rdonly_root = B_FALSE;
 
+static boolean_t
+strings_differ(const char *a, const char *b)
+{
+	if (a && !b)
+		return (B_TRUE);
+	if (!a && b)
+		return (B_TRUE);
+	if (a && b && strcmp(a, b))
+		return (B_TRUE);
+
+	return (B_FALSE);
+}
+
 /*
  * Checks if the database nvl, `db_nvl' contains and matches ALL of the passed
  * in private nvpairs `proto', `ifname' & `aobjname'.
@@ -102,28 +115,15 @@
 			(void) nvpair_value_string(nvp, &db_aobjname);
 	}
 
-	if (proto != NULL && proto[0] == '\0')
-		proto = NULL;
-	if (ifname != NULL && ifname[0] == '\0')
-		ifname = NULL;
-	if (aobjname != NULL && aobjname[0] == '\0')
-		aobjname = NULL;
-
-	if ((proto == NULL && db_proto != NULL) ||
-	    (proto != NULL && db_proto == NULL) ||
-	    strcmp(proto, db_proto) != 0) {
+	if (strings_differ(proto, db_proto)) {
 		/* no intersection - different protocols. */
 		return (B_FALSE);
 	}
-	if ((ifname == NULL && db_ifname != NULL) ||
-	    (ifname != NULL && db_ifname == NULL) ||
-	    strcmp(ifname, db_ifname) != 0) {
+	if (strings_differ(ifname, db_ifname)) {
 		/* no intersection - different interfaces. */
 		return (B_FALSE);
 	}
-	if ((aobjname == NULL && db_aobjname != NULL) ||
-	    (aobjname != NULL && db_aobjname == NULL) ||
-	    strcmp(aobjname, db_aobjname) != 0) {
+	if (strings_differ(aobjname, db_aobjname)) {
 		/* no intersection - different address objects */
 		return (B_FALSE);
 	}