From 6fbd9acc05bde03c1d6acfc8256d2bb411c0cc00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Eivind=20N=C3=A6ss?= Date: Thu, 23 Sep 2021 07:44:06 -0700 Subject: [PATCH] CLang detected possible invalid memory access (-Wsizeof-pointer-memaccess) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit rc_find_server() resets the secret by setting *secret = 0 instead of what was likely intended: memset the entire array. In case of error, moved the memset operation outside of the rc_find_server() function. It's only used in one place anyway. Signed-off-by: Eivind Næss --- pppd/plugins/radius/config.c | 1 - pppd/plugins/radius/sendserver.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pppd/plugins/radius/config.c b/pppd/plugins/radius/config.c index 871cea0..47c172c 100644 --- a/pppd/plugins/radius/config.c +++ b/pppd/plugins/radius/config.c @@ -525,7 +525,6 @@ int rc_find_server (char *server_name, UINT4 *ip_addr, char *secret) if (result == 0) { memset (buffer, '\0', sizeof (buffer)); - memset (secret, '\0', sizeof (secret)); error("rc_find_server: couldn't find RADIUS server %s in %s", server_name, rc_conf_str("servers")); return (-1); diff --git a/pppd/plugins/radius/sendserver.c b/pppd/plugins/radius/sendserver.c index 0c0ef30..d7bebdb 100644 --- a/pppd/plugins/radius/sendserver.c +++ b/pppd/plugins/radius/sendserver.c @@ -228,6 +228,7 @@ int rc_send_server (SEND_DATA *data, char *msg, REQUEST_INFO *info) { if (rc_find_server (server_name, &auth_ipaddr, secret) != 0) { + memset (secret, '\0', sizeof (secret)); return (ERROR_RC); } } -- 2.39.2