[PATCH uclient 07/12] uclient-fetch: fix potential memory leaks
Petr Štetiar
ynezz at true.cz
Thu Dec 10 10:47:54 EST 2020
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 <ynezz at true.cz>
---
uclient-fetch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/uclient-fetch.c b/uclient-fetch.c
index 0c7a1232f256..1c66ac6d33ae 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:
More information about the openwrt-devel
mailing list