]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: connect: Fix segfault during open authentication
authorChaitanya Tata <chaitanya.mgit@gmail.com>
Wed, 26 Jul 2023 19:22:45 +0000 (00:52 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 24 Aug 2023 07:17:39 +0000 (09:17 +0200)
The check for remaining arguments is done after decrement effectively
bypassing the non-zero check and causes a segfault with below command:

  "connect <SSID> auth open/shared".

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Link: https://lore.kernel.org/r/20230726192245.100897-1-Chaitanya.Tata@nordicsemi.no
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
connect.c

index e5b177f042e0eab794d08d825f6c976dd71a435a..33e1a5fb83c49518851b9a8c0e8f9cf0ab9bf826 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -77,6 +77,9 @@ static int iw_conn(struct nl80211_state *state,
        if (argc && strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
                return 1;
 
+       if (!argc)
+               return 0;
+
        argv++;
        argc--;