aboutsummaryrefslogtreecommitdiff
path: root/src/core
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/core
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/core')
-rw-r--r--src/core/string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/string.c b/src/core/string.c
index c35015b..188fe08 100644
--- a/src/core/string.c
+++ b/src/core/string.c
@@ -116,7 +116,7 @@ int memcmp ( const void *first, const void *second, size_t len ) {
int diff;
while ( len-- ) {
- diff = ( *(second_bytes++) - *(first_bytes++) );
+ diff = ( *(first_bytes++) - *(second_bytes++) );
if ( diff )
return diff;
}