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 <yn...@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:

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to