Source: ifupdown
Version: 0.8.23
Severity: important
Tags: patch
User: [email protected]
Usertags: hurd, kfreebsd

Hi,

ifupdown FTBFS due to a trivial omission to install <stdio.h> on both
Hurd and kFreeBSD in files archhurd.c and archkfreebsd.c, respectively.
Additionally the function expand_matches() needs some fixes to cope
with Hurd naming network interfaces e.g. /dev/eth0 instead of eth0.

I think we should continue the effort to remove global variables
further, and provide test cases for the new functionality. Next would
be a test for the rename option as well as ifquery. I'm pretty sure
ifquery can be supported for Hurd too. For kFreeBSD I'm more unsure, I
just checked that the build was OK with the proposed patch.

Thanks :)
Index: ifupdown-0.8.23/main.c
===================================================================
--- ifupdown-0.8.23.orig/main.c
+++ ifupdown-0.8.23/main.c
@@ -650,22 +650,24 @@ static struct ifaddrs *ifap = NULL;
 static void expand_matches(int *argc, char ***argv) {
 	char **exp_iface = NULL;
 	int n_exp_ifaces = 0;
+	char *buf = NULL;
 
 	for (int i = 0; i < *argc; i++) {
 		// Interface names not containing a slash are taken over literally.
-		if (!strchr((*argv)[i], '/')) {
+		buf = strdupa((*argv)[i]);
+		sanitize_file_name(buf);
+		if (!strchr(buf, '/')) {
 			append_to_list_nodup(&exp_iface, &n_exp_ifaces, (*argv)[i]);
 			continue;
 		}
 
 		// Format is [variable]/pattern[/options]
-		char *buf = strdupa((*argv)[i]);
 		char *variable = NULL;
 		char *pattern = NULL;
 		char *options = NULL;
 		int match_n = 0;
 
-		char *slash = strchr(buf, '/');
+		char *slash = strchrnul(buf, '/');
 		if (slash != buf)
 			variable = buf;
 		*slash++ = 0;
Index: ifupdown-0.8.23/archkfreebsd.c
===================================================================
--- ifupdown-0.8.23.orig/archkfreebsd.c
+++ ifupdown-0.8.23/archkfreebsd.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include "archcommon.h"
 
 bool variable_match(const char *iface, const char *variable, const char *pattern) {
Index: ifupdown-0.8.23/archhurd.c
===================================================================
--- ifupdown-0.8.23.orig/archhurd.c
+++ ifupdown-0.8.23/archhurd.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include "archcommon.h"
 
 bool variable_match(const char *iface, const char *variable, const char *pattern) {

Reply via email to