Skip to contentSkip to conversation

monitor: fix spelling Exausted -> Exhausted

PATCH Superseded James Prestwood 2 participants 11 messages Apr 16, 2025 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/9 monitor: fix spelling Exausted -> Exhausted

Caught by codespell

---
 monitor/nlmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/nlmon.c +1 -1
index 76eb2db6..14a29eab 100644
@@ -7433,7 +7433,7 @@ static bool check_pcap(struct nlmon *nlmon, size_t next_size)
 
 	pcap_close(nlmon->pcap);
 
-	/* Exausted the single PCAP file */
+	/* Exhausted the single PCAP file */
 	if (nlmon->max_files < 2) {
 		printf("Reached maximum size of PCAP, exiting\n");
 		nlmon->pcap = NULL;
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/9 scan: fix out of bound array access for survey results

The survey arrays were exactly the number of valid channels for a given band (e.g. 14 for 2.4GHz) but since channels start at 1 this means that the last channel for a band would overflow the array.

---
 src/scan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/scan.c +3 -3
index aeab6516..dfd667bb 100644
@@ -143,9 +143,9 @@ struct scan_survey {
 };
 
 struct scan_survey_results {
-	struct scan_survey survey_2_4[14];
-	struct scan_survey survey_5[196];
-	struct scan_survey survey_6[233];
+	struct scan_survey survey_2_4[15];
+	struct scan_survey survey_5[197];
+	struct scan_survey survey_6[234];
 };
 
 struct scan_results {
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/9] scan: fix out of bound array access for survey results

Hi James,

Quoted 7 lines · James Prestwood

The survey arrays were exactly the number of valid channels for a given band (e.g. 14 for 2.4GHz) but since channels start at 1 this means that the last channel for a band would overflow the array.

---
  src/scan.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Can I get some Fixes: tags for these?

Regards,
-Denis

#3 lore raw

Re: [PATCH 2/9] scan: fix out of bound array access for survey results

Quoted 11 lines · Denis Kenzior

Hi James,

Quoted 7 lines · James Prestwood

The survey arrays were exactly the number of valid channels for a given band (e.g. 14 for 2.4GHz) but since channels start at 1 this means that the last channel for a band would overflow the array.
---
  src/scan.c | 6 +++---

  1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 1 line

Can I get some Fixes: tags for these?

Sure, I'll see what I can gather up.

Quoted 3 lines

Regards,
-Denis

#4 lore raw

PATCH 3/9 dpp-util: fail on duplicate values in URI

In reply to James Prestwood

The MAC and version elements weren't super critical but the channel and bootstrapping key elements would result in memory leaks if there were duplicates.

This patch now will not allow duplicate elements in the URI.

---
 src/dpp-util.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
src/dpp-util.c +13 -0
index cfdedbdd..1986a5cc 100644
@@ -1166,21 +1166,34 @@ struct dpp_uri_info *dpp_parse_uri(const char *uri)
 
 		switch (*pos) {
 		case 'C':
+			if (L_WARN_ON(info->freqs))
+				goto free_info;
+
 			info->freqs = dpp_parse_class_and_channel(pos + 2, len);
 			if (!info->freqs)
 				goto free_info;
 			break;
 		case 'M':
+			if (L_WARN_ON(!l_memeqzero(info->mac,
+							sizeof(info->mac))))
+				goto free_info;
+
 			ret = dpp_parse_mac(pos + 2, len, info->mac);
 			if (ret < 0)
 				goto free_info;
 			break;
 		case 'V':
+			if (L_WARN_ON(info->version != 0))
+				goto free_info;
+
 			ret = dpp_parse_version(pos + 2, len, &info->version);
 			if (ret < 0)
 				goto free_info;
 			break;
 		case 'K':
+			if (L_WARN_ON(info->boot_public))
+				goto free_info;
+
 			info->boot_public = dpp_parse_key(pos + 2, len);
 			if (!info->boot_public)
 				goto free_info;
Signature · 1 line
2.34.1
#5 lore raw

PATCH 4/9 unit: add test for duplicate URI elements

In reply to James Prestwood
---
 unit/test-dpp.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
unit/test-dpp.c +32 -0
index 70e79814..af2f5813 100644
@@ -116,6 +116,29 @@ struct dpp_test_info bad_channels[] = {
 	},
 };
 
+struct dpp_test_info duplicates[] = {
+	/* Duplicate key */
+	{
+		.uri = "DPP:K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;",
+		.expect_fail = true
+	},
+	/* Duplicate frequencies*/
+	{
+		.uri = "DPP:C:81/1,115/36;C:81/1,115/36;;",
+		.expect_fail = true
+	},
+	/* Duplicate MACs*/
+	{
+		.uri = "DPP:M:5254005828e5;M:5254005828e5;;",
+		.expect_fail = true
+	},
+	/* Duplicate versions */
+	{
+		.uri = "DPP:V:2;V:2;;",
+		.expect_fail = true
+	},
+};
+
 static bool verify_info(const struct dpp_uri_info *parsed,
 			const struct dpp_test_info *result)
 {
@@ -158,6 +181,14 @@ static void test_bad_channels(const void *data)
 		test_uri_parse(&bad_channels[i]);
 }
 
+static void test_duplicate_in_uri(const void *data)
+{
+	unsigned int i;
+
+	for (i = 0; i < L_ARRAY_SIZE(duplicates); i++)
+		test_uri_parse(&duplicates[i]);
+}
+
 struct dpp_test_vector {
 	/* Initiator values */
 	const char *i_proto_public;
@@ -576,6 +607,7 @@ int main(int argc, char *argv[])
 	l_test_add("DPP URI bad key", test_uri_parse, &bad_key);
 	l_test_add("DPP URI bad channels", test_bad_channels, &bad_channels);
 	l_test_add("DPP URI unexpected ID", test_uri_parse, &unexpected_id);
+	l_test_add("DPP URI duplicates", test_duplicate_in_uri, &duplicates);
 
 	return l_test_run();
 }
Signature · 1 line
2.34.1
#6 lore raw

PATCH 5/9 monitor: add size check for interworking IE parsing

In reply to James Prestwood
---
 monitor/nlmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/nlmon.c +1 -1
index 14a29eab..7924f6f2 100644
@@ -1915,7 +1915,7 @@ static void print_ie_interworking(unsigned int level,
 	size--;
 	ptr++;
 
-	if (!size)
+	if (size < 2)
 		return;
 
 	/*
Signature · 1 line
2.34.1
#7 lore raw

PATCH 6/9 storage: add length check in __storage_decrypt

In reply to James Prestwood

The length of EncryptedSecurity was assumed to be at least 16 bytes and anything less would underflow the length to l_malloc.

---
 src/storage.c | 7 +++++++
 1 file changed, 7 insertions(+)
src/storage.c +7 -0
index 843581fd..2115a879 100644
@@ -500,6 +500,13 @@ int __storage_decrypt(struct l_settings *settings, const char *ssid,
 		return 0;
 	}
 
+	/*
+	 * It should likely be far larger than this, but that will get caught
+	 * later when reloading the decrypted data.
+	 */
+	if (elen < 16)
+		return -EBADMSG;
+
 	/*
 	 * AES-SIV automatically verifies the IV (16 bytes) and returns only
 	 * the decrypted data portion. We add one here for the NULL terminator
Signature · 1 line
2.34.1
#8 lore raw

PATCH 7/9 unit: add test-storage

In reply to James Prestwood

For now, a single test for __storage_decrypt that ensures an invalid length fails as expected.

---
 Makefile.am         |  7 +++++-
 unit/test-storage.c | 55 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 unit/test-storage.c
Makefile.am +6 -1
index 6404bdbb..92adfa6e 100644
@@ -441,7 +441,7 @@ unit_tests += unit/test-cmac-aes \
 		unit/test-arc4 unit/test-wsc unit/test-eap-mschapv2 \
 		unit/test-eap-sim unit/test-sae unit/test-p2p unit/test-band \
 		unit/test-dpp unit/test-json unit/test-nl80211util \
-		unit/test-pmksa
+		unit/test-pmksa unit/test-storage
 endif
 
 if CLIENT
@@ -605,6 +605,11 @@ unit_test_nl80211util_LDADD = $(ell_ldadd)
 unit_test_pmksa_SOURCES = unit/test-pmksa.c src/pmksa.c src/pmksa.h \
 				src/module.h src/util.h
 unit_test_pmksa_LDADD = $(ell_ldadd)
+
+unit_test_storage_SOURCES = unit/test-storage.c src/storage.c src/storage.h \
+				src/crypto.c src/crypto.h \
+				src/common.c src/common.h
+unit_test_storage_LDADD = $(ell_ldadd)
 endif
 
 if CLIENT
unit/test-storage.c new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.34.1
#9 lore raw

PATCH 8/9 station: check return when advancing iterator

In reply to James Prestwood
---
 src/station.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/station.c +2 -1
index 9972ea76..14c93671 100644
@@ -4836,7 +4836,8 @@ static struct l_dbus_message *station_property_set_affinities(
 		return dbus_error_invalid_args(message);
 
 	/* Get first entry, there should be only one */
-	l_dbus_message_iter_next_entry(&array, &new_path);
+	if (!l_dbus_message_iter_next_entry(&array, &new_path))
+		return dbus_error_invalid_args(message);
 
 	if (l_dbus_message_iter_next_entry(&array, &new_path))
 		return dbus_error_invalid_args(message);
Signature · 1 line
2.34.1
#10 lore raw

PATCH 9/9 eap-mschapv2: Fix leak of state->user on error path

In reply to James Prestwood
---
 src/eap-mschapv2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/eap-mschapv2.c +2 -1
index 1639f578..00976d73 100644
@@ -544,7 +544,8 @@ static bool eap_mschapv2_load_settings(struct eap_state *eap,
 	return true;
 
 error:
-	free(state);
+	l_free(state->user);
+	l_free(state);
 	return false;
 }
 
Signature · 1 line
2.34.1