From 90e1f4ec3ea9f0882b108cbb8887c5256edad02b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 7 Jan 2017 19:50:05 -0700 Subject: [PATCH] Fix crash in visudo introduced in sudo 1.8.9 when an IP address or network is used in a host-based Defaults entry. Bug #766 --- MANIFEST | 2 ++ plugins/sudoers/interfaces.c | 2 +- plugins/sudoers/regress/visudo/test9.out.ok | 1 + plugins/sudoers/regress/visudo/test9.sh | 12 ++++++++++++ plugins/sudoers/visudo.c | 7 +++++-- 5 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 plugins/sudoers/regress/visudo/test9.out.ok create mode 100755 plugins/sudoers/regress/visudo/test9.sh diff --git a/MANIFEST b/MANIFEST index cb7146de8..db59f4292 100644 --- 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 diff --git a/plugins/sudoers/interfaces.c b/plugins/sudoers/interfaces.c index 2a868b59e..d1b4dae75 100644 --- a/plugins/sudoers/interfaces.c +++ b/plugins/sudoers/interfaces.c @@ -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 index 000000000..e5c355c2e --- /dev/null +++ b/plugins/sudoers/regress/visudo/test9.out.ok @@ -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 index 000000000..d62fb8839 --- /dev/null +++ b/plugins/sudoers/regress/visudo/test9.sh @@ -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 diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index b2ee89486..4f192b209 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -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; } /* -- 2.40.0