From 86a2ac6ac46ffb3f71e84debd03f7f16add148e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Tue, 8 Dec 2020 17:45:19 +0100 Subject: uclient-fetch: fix potential memory leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes following issue reported by clang-12 static analyzer: uclient-fetch.c:612:25: warning: Potential leak of memory pointed to by 'username' [unix.Malloc] memset(optarg, '*', strlen(optarg)); ^~~~~~~~~~~~~~ uclient-fetch.c:618:25: warning: Potential leak of memory pointed to by 'password' [unix.Malloc] memset(optarg, '*', strlen(optarg)); ^~~~~~~~~~~~~~ Signed-off-by: Petr Štetiar --- uclient-fetch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uclient-fetch.c b/uclient-fetch.c index 0c7a123..1c66ac6 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -608,13 +608,13 @@ int main(int argc, char **argv) case L_USER: if (!strlen(optarg)) break; - username = strdup(optarg); + username = strdupa(optarg); memset(optarg, '*', strlen(optarg)); break; case L_PASSWORD: if (!strlen(optarg)) break; - password = strdup(optarg); + password = strdupa(optarg); memset(optarg, '*', strlen(optarg)); break; case L_USER_AGENT: -- cgit v1.2.1