]> granicus.if.org Git - sudo/commitdiff
Fix crash in visudo introduced in sudo 1.8.9 when an IP address or
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 8 Jan 2017 02:50:05 +0000 (19:50 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 8 Jan 2017 02:50:05 +0000 (19:50 -0700)
network is used in a host-based Defaults entry.  Bug #766

MANIFEST
plugins/sudoers/interfaces.c
plugins/sudoers/regress/visudo/test9.out.ok [new file with mode: 0644]
plugins/sudoers/regress/visudo/test9.sh [new file with mode: 0755]
plugins/sudoers/visudo.c

index cb7146de8259eee11e250b48b849010f5f578a6e..db59f42928e74f49cb6fa0648682bde2927302ca 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -472,6 +472,8 @@ plugins/sudoers/regress/visudo/test7.sh
 plugins/sudoers/regress/visudo/test8.err.ok
 plugins/sudoers/regress/visudo/test8.out.ok
 plugins/sudoers/regress/visudo/test8.sh
+plugins/sudoers/regress/visudo/test9.out.ok
+plugins/sudoers/regress/visudo/test9.sh
 plugins/sudoers/set_perms.c
 plugins/sudoers/solaris_audit.c
 plugins/sudoers/solaris_audit.h
index 2a868b59e7fb9095bf3fa94c5e2adc95af2ea6ba..d1b4dae75b0a9155c82a58f8b6b6ea6ca748c6bc 100644 (file)
@@ -43,7 +43,7 @@
 # define INADDR_NONE ((unsigned int)-1)
 #endif
 
-static struct interface_list interfaces;
+static struct interface_list interfaces = SLIST_HEAD_INITIALIZER(interfaces);
 
 /*
  * Parse a space-delimited list of IP address/netmask pairs and
diff --git a/plugins/sudoers/regress/visudo/test9.out.ok b/plugins/sudoers/regress/visudo/test9.out.ok
new file mode 100644 (file)
index 0000000..e5c355c
--- /dev/null
@@ -0,0 +1 @@
+stdin: parsed OK
diff --git a/plugins/sudoers/regress/visudo/test9.sh b/plugins/sudoers/regress/visudo/test9.sh
new file mode 100755 (executable)
index 0000000..d62fb88
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# Test IP and network address in host-based Defaults statements
+# Bugzilla #766
+#
+
+./visudo -cf - <<-EOF
+       Defaults@127.0.0.1 !authenticate
+       Defaults@10.0.0.0/8 !always_set_home
+       EOF
+
+exit 0
index b2ee8948673929fc5ba82ad2ebea5bc0d8a96687..4f192b2094fe9dab3a1dc976c67e56ea8e0e84ca 100644 (file)
@@ -61,6 +61,7 @@
 #endif
 
 #include "sudoers.h"
+#include "interfaces.h"
 #include "parse.h"
 #include "redblack.h"
 #include "sudoers_version.h"
@@ -815,9 +816,11 @@ group_plugin_query(const char *user, const char *group, const struct passwd *pw)
 }
 
 /* STUB */
-struct interface *get_interfaces(void)
+struct interface_list *
+get_interfaces(void)
 {
-    return NULL;
+    static struct interface_list dummy = SLIST_HEAD_INITIALIZER(interfaces);
+    return &dummy;
 }
 
 /*