From 999672b466b8b6563c606af00d1190732c1314e3 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Fri, 19 Jan 2024 01:50:11 -0800 Subject: [PATCH] sources/auth_query.c: handle malloc failure (#555) --- sources/auth_query.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sources/auth_query.c b/sources/auth_query.c index 12c2fb0fb..922671dcc 100644 --- a/sources/auth_query.c +++ b/sources/auth_query.c @@ -145,6 +145,9 @@ int od_auth_query(od_client_t *client, char *peer) if (cache_value->passwd_len > 0) { /* */ password->password = malloc(password->password_len + 1); + if (password->password == NULL) { + goto error; + } strncpy(password->password, cache_value->passwd, cache_value->passwd_len); password->password[password->password_len] = '\0'; @@ -259,6 +262,9 @@ int od_auth_query(od_client_t *client, char *peer) } cache_value->passwd_len = password->password_len; cache_value->passwd = malloc(password->password_len); + if (cache_value->passwd == NULL) { + goto error; + } strncpy(cache_value->passwd, password->password, cache_value->passwd_len);