Skip to contentSkip to conversation

fix SIGSEGV when yp domain not bound

PATCH In review Jeff Moyer 2 participants 2 messages May 4, 2004 – May 5, 2004 Kernel automounter

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 fix SIGSEGV when yp domain not bound

Hi Ian, list,

If you happen to find your systems unable to communicate with the yp server, the subprocess launched to automount a share will receive a SIGSEGV, because we only check for err == YPERR_KEY in the lookup_yp module. We get a different error, of course, and then go on to do a cache_update with NULL values. Here is a patch which addresses this issue. Comments more than welcome. Oh, and I took the liberty of doing minor reformatting; I hope you don't mind, Ian.

-Jeff

modules/lookup_yp.c renamed from modules/lookup_yp.c~ +23 -15
@@ -195,19 +195,26 @@
 	}
 
 	if (!me) {
-		/* For reasons unknown, the standard YP definitions doesn't define input
-		   strings as const char *.  However, my understanding is that they will
-		   not be modified by the library. */
+		/* For reasons unknown, the standard YP definitions doesn't
+		   define input strings as const char *.  However, my
+		   understanding is that they will not be modified by the
+		   library. */
 		err = yp_match((char *) ctxt->domainname, (char *) ctxt->mapname,
 			       (char *) name, name_len, &mapent, &mapent_len);
 
-		if (err == YPERR_KEY) {
+		if (err != YPERR_SUCCESS) {
+			if (err != YPERR_KEY)
+				goto out_err;
+
 			/* See if there is an entry "root/name" */
 			key_len = sprintf(key, "%s/%s", root, name);
-			err = yp_match((char *) ctxt->domainname, (char *) ctxt->mapname,
+			err = yp_match((char *) ctxt->domainname, 
+				       (char *) ctxt->mapname,
 				       key, key_len, &mapent, &mapent_len);
 
-			if (err == YPERR_KEY) {
+			if (err != YPERR_SUCCESS) {
+				if (err != YPERR_KEY)
+					goto out_err;
 				/* 
 				 * Try to get the "*" entry if there is one i
 				 * - note that we *don't* modify "name" so
@@ -215,18 +222,13 @@
 				 */
 				err =
 				    yp_match((char *) ctxt->domainname,
-					     (char *) ctxt->mapname, "*", 1, &mapent,
-					     &mapent_len);
+					     (char *) ctxt->mapname, "*", 1, 
+					     &mapent, &mapent_len);
 			} else
 				cache_update(key, mapent, age);
 
-			if (err) {
-				warn(MODPREFIX "lookup for %s failed: %s", name,
-				     yperr_string(err));
-				if (mapent)
-					free(mapent);
-				return 1;
-			}
+			if (err)
+				goto out_err;
 		} else
 			cache_update(name, mapent, age);
 	}
@@ -238,6 +240,12 @@
 	rv = ctxt->parse->parse_mount(root, name, name_len, mapent, ctxt->parse->context);
 	free(mapent);
 	return rv;
+
+out_err:
+	warn(MODPREFIX "lookup for %s failed: %s", name, yperr_string(err));
+	if (mapent)
+		free(mapent);
+	return 1;
 }
 
 int lookup_done(void *context)
maintainer
#1 lore raw
Quoted 10 lines · Jeff Moyer

Hi Ian, list,

If you happen to find your systems unable to communicate with the yp server, the subprocess launched to automount a share will receive a SIGSEGV, because we only check for err == YPERR_KEY in the lookup_yp module. We get a different error, of course, and then go on to do a cache_update with NULL values. Here is a patch which addresses this issue. Comments more than welcome. Oh, and I took the liberty of doing minor reformatting; I hope you don't mind, Ian.

Cool. Looks good to me.

Ian