From 4457f41b545087065680d1755f6ca4e6753e3459 Mon Sep 17 00:00:00 2001 From: Maneesh Jain Date: Mon, 22 Jun 2015 09:02:15 +0530 Subject: [PATCH] radius: Fix NULL dereference issue on allocation failure In case memory allocation fails, data->pac_opaque_encr_key may be NULL and lead to possible crash. Signed-off-by: Maneesh Jain --- src/radius/radius_server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/radius/radius_server.c b/src/radius/radius_server.c index 1c699555e..bdb7e42c5 100644 --- a/src/radius/radius_server.c +++ b/src/radius/radius_server.c @@ -1711,8 +1711,10 @@ radius_server_init(struct radius_server_conf *conf) data->ipv6 = conf->ipv6; if (conf->pac_opaque_encr_key) { data->pac_opaque_encr_key = os_malloc(16); - os_memcpy(data->pac_opaque_encr_key, conf->pac_opaque_encr_key, - 16); + if (data->pac_opaque_encr_key) { + os_memcpy(data->pac_opaque_encr_key, + conf->pac_opaque_encr_key, 16); + } } if (conf->eap_fast_a_id) { data->eap_fast_a_id = os_malloc(conf->eap_fast_a_id_len);