From e2e3ee6ac47fe1bbde6823541bb56e9a45fa63aa Mon Sep 17 00:00:00 2001 From: reshke Date: Mon, 13 Nov 2023 16:25:49 +0500 Subject: [PATCH] Fix segfault on empty password (#542) --- sources/auth_query.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sources/auth_query.c b/sources/auth_query.c index 0710f63f0..1662af975 100644 --- a/sources/auth_query.c +++ b/sources/auth_query.c @@ -142,10 +142,13 @@ int od_auth_query(od_client_t *client, char *peer) user->name_len, user->name); /* unlock hashmap entry */ password->password_len = cache_value->passwd_len; - password->password = malloc(password->password_len + 1); - strncpy(password->password, cache_value->passwd, - cache_value->passwd_len); - password->password[password->password_len] = '\0'; + if (cache_value->passwd_len > 0) { + /* */ + password->password = malloc(password->password_len + 1); + strncpy(password->password, cache_value->passwd, + cache_value->passwd_len); + password->password[password->password_len] = '\0'; + } od_hashmap_unlock_key(storage->acache, keyhash, &key); return OK_RESPONSE; }