From 0f84a72e3c0f58d71cff2121e6df1611eaf9c9ea Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 27 Nov 2014 16:08:46 +0100 Subject: resolve: fix NULL deref on strv comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A strv might be NULL if it is empty. The txt.strings comparison doesn't take that into account. Introduce strv_equal() to provide a proper helper for this and fix resolve to use it. Thanks to Stanisław Pitucha for reporting this! --- src/shared/strv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/shared/strv.c') diff --git a/src/shared/strv.c b/src/shared/strv.c index aeb93eac6b..a5f8a2aff6 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -587,6 +587,17 @@ char **strv_sort(char **l) { return l; } +bool strv_equal(char **a, char **b) { + if (!a || !b) + return a == b; + + for ( ; *a || *b; ++a, ++b) + if (!streq_ptr(*a, *b)) + return false; + + return true; +} + void strv_print(char **l) { char **s; -- cgit v1.2.3-54-g00ecf