aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMichael J. Bazzinotti <mbazzinotti@gmail.com>2020-01-14 13:15:02 -0500
committerMichael Brown <mcb30@ipxe.org>2020-07-21 15:29:18 +0100
commit0de5e601440bdb1f244b054384d6f77cefc86ba7 (patch)
treedbfa6747619a410b2bec5a8e014bf8c6e23510cc /src/tests
parent6ec33b8d6cc607579fcc90f551146831890d2070 (diff)
downloadipxe-0de5e601440bdb1f244b054384d6f77cefc86ba7.zip
ipxe-0de5e601440bdb1f244b054384d6f77cefc86ba7.tar.gz
ipxe-0de5e601440bdb1f244b054384d6f77cefc86ba7.tar.bz2
[libc] Fix memcmp() to return proper values
Fix memcmp() to return proper standard positive/negative values for unequal comparisons. Current implementation is backwards (i.e. the functions are returning negative when should be positive and vice-versa). Currently most consumers of these functions only check the return value for ==0 or !=0 and so we can safely change the implementation without breaking things. However, there is one call that checks the polarity of this function, and that is prf_sha1() for wireless WPA 4-way handshake. Due to the incorrect memcmp() polarity, the WPA handshake creates an incorrect PTK, and the handshake would fail after step 2. Undoubtedly, the AP noticed the supplicant failed the mic check. This commit fixes that issue. Similar to commit 3946aa9 ("[libc] Fix strcmp()/strncmp() to return proper values"). Signed-off-by: Michael Bazzinotti <bazz@bazz1.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/string_test.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/tests/string_test.c b/src/tests/string_test.c
index a66501d..88a730a 100644
--- a/src/tests/string_test.c
+++ b/src/tests/string_test.c
@@ -109,6 +109,7 @@ static void string_test_exec ( void ) {
ok ( memcmp ( "", "", 0 ) == 0 );
ok ( memcmp ( "Foo", "Foo", 3 ) == 0 );
ok ( memcmp ( "Foo", "Bar", 3 ) != 0 );
+ ok ( memcmp ( "abc", "def", 3 ) < 0 );
/* Test strstr() */
{