Hello again, as promised, the patch.
Thanks, Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
From df705b1453d08b89d116a3c17eabaf8fd89a0de3 Mon Sep 17 00:00:00 2001 From: Martin Pitt <[email protected]> Date: Tue, 12 Jan 2016 08:11:36 +0100 Subject: [PATCH] Fix ifquery crash if interface state file does not exist yet We do this in do_interface(): char *current_state; lock = lock_interface(iface, ¤t_state); current_state is a stack variable and thus could have a random value. For "ifquery" (or --no-act), lock_interface() does not exit(1) on failure but returns NULL instead. This happens if if /run/network/ifstate.<iface> does not exist (yet), then lock == NULL, and current_state does not get written to as that's an early exit path in lock_interface(). Then do_interface progresses into the "else if (cmds == iface_query)" branch, current_state != NULL is satisfied, and strncpy() gets called on the uninitialized value. Fix this by initializing current_state to NULL. Closes: #810779 LP: #1532722 --- debian/changelog | 7 +++++++ main.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 044379c..1db3cfd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ifupdown (0.8.8) UNRELEASED; urgency=medium + + * Fix ifquery crash if interface state file does not exist yet. + (Closes: #810779, LP: #1532722) + + -- Martin Pitt <[email protected]> Tue, 12 Jan 2016 08:07:23 +0100 + ifupdown (0.8.7) unstable; urgency=medium * Impose a 5 minute timeout for starting network services. diff --git a/main.c b/main.c index 231d69e..c95d4ec 100644 --- a/main.c +++ b/main.c @@ -843,7 +843,7 @@ static bool do_interface(const char *target_iface) { bool success = false; FILE *lock = NULL; - char *current_state; + char *current_state = NULL; lock = lock_interface(iface, ¤t_state); -- 2.7.0.rc3
signature.asc
Description: Digital signature

