changeset 21330:eb456cb34cac

auth: do NOT feed p_strconcat() with NULL p_strconcat will never take NULL as an valid argument. Check possible NULL string before calling it.
author Baofeng <baofeng.wang@dovecot.com>
date Mon, 11 Apr 2016 21:20:48 +0300
parents a6116b23e7e9
children 0fcd4cdd97ed
files src/auth/auth.c
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth.c	Sat Dec 17 11:31:42 2016 +0200
+++ b/src/auth/auth.c	Mon Apr 11 21:20:48 2016 +0300
@@ -95,9 +95,14 @@
 
 	auth_passdb->passdb = passdb_preinit(auth->pool, set);
 	/* make sure any %variables in default_fields exist in cache_key */
-	auth_passdb->cache_key =
-		p_strconcat(auth->pool, auth_passdb->passdb->default_cache_key,
-			    set->default_fields, NULL);
+	if (auth_passdb->passdb->default_cache_key != NULL) {
+		auth_passdb->cache_key =
+			p_strconcat(auth->pool, auth_passdb->passdb->default_cache_key,
+				set->default_fields, NULL);
+	}
+	else {
+		auth_passdb->cache_key = NULL;
+	}
 }
 
 static void
@@ -127,9 +132,14 @@
 
 	auth_userdb->userdb = userdb_preinit(auth->pool, set);
 	/* make sure any %variables in default_fields exist in cache_key */
-	auth_userdb->cache_key =
-		p_strconcat(auth->pool, auth_userdb->userdb->default_cache_key,
-			    set->default_fields, NULL);
+	if (auth_userdb->userdb->default_cache_key != NULL) {
+		auth_userdb->cache_key =
+			p_strconcat(auth->pool, auth_userdb->userdb->default_cache_key,
+				    set->default_fields, NULL);
+	}
+	else {
+		auth_userdb->cache_key = NULL;
+	}
 }
 
 static bool auth_passdb_list_have_verify_plain(const struct auth *auth)