]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add a module test for wpa_ssid_txt() with too long SSID
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 7 Apr 2015 12:52:34 +0000 (15:52 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 22 Apr 2015 08:44:19 +0000 (11:44 +0300)
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com
src/utils/utils_module_tests.c

index 4b97dadd786c6c4f7a22ee236355fce0ee58571e..b2c7e08a17d3204d0fb22df3d323ce5e356e7837 100644 (file)
@@ -9,6 +9,7 @@
 #include "utils/includes.h"
 
 #include "utils/common.h"
+#include "common/ieee802_11_defs.h"
 #include "utils/bitfield.h"
 #include "utils/ext_password.h"
 #include "utils/trace.h"
@@ -340,6 +341,9 @@ static int common_tests(void)
        u8 bin[3];
        int errors = 0;
        struct wpa_freq_range_list ranges;
+       size_t len;
+       const char *txt;
+       u8 ssid[255];
 
        wpa_printf(MSG_INFO, "common tests");
 
@@ -395,6 +399,16 @@ static int common_tests(void)
        if (utf8_escape("a", 0, buf, sizeof(buf)) != 1 || buf[0] != 'a')
                errors++;
 
+       os_memset(ssid, 0, sizeof(ssid));
+       txt = wpa_ssid_txt(ssid, sizeof(ssid));
+       len = os_strlen(txt);
+       /* Verify that SSID_MAX_LEN * 4 buffer limit is enforced. */
+       if (len != SSID_MAX_LEN * 4) {
+               wpa_printf(MSG_ERROR,
+                          "Unexpected wpa_ssid_txt() result with too long SSID");
+               errors++;
+       }
+
        if (errors) {
                wpa_printf(MSG_ERROR, "%d common test(s) failed", errors);
                return -1;