From c2189bc67e1cc3ebb53a5dc071e2612b7be11d03 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 11 Jan 2019 09:16:05 -0800 Subject: [PATCH] sae: fix one-off error in sae_is_quadradic_residue This fixes the valgrind warning: ==14804== Conditional jump or move depends on uninitialised value(s) ==14804== at 0x402E56: sae_is_quadradic_residue (sae.c:218) ==14804== by 0x402E56: sae_compute_pwe (sae.c:272) ==14804== by 0x402E56: sae_build_commit (sae.c:333) ==14804== by 0x402E56: sae_send_commit (sae.c:591) ==14804== by 0x401CC3: test_confirm_after_accept (test-sae.c:454) ==14804== by 0x408A28: l_test_run (test.c:83) ==14804== by 0x401427: main (test-sae.c:566) --- src/sae.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sae.c b/src/sae.c index bbe4f1ca..12e653d3 100644 --- a/src/sae.c +++ b/src/sae.c @@ -215,7 +215,7 @@ static bool sae_is_quadradic_residue(const struct l_ecc_curve *curve, return false; } - if (rbuf[bytes / 8] & 1) { + if (rbuf[bytes / 8 - 1] & 1) { l_ecc_scalar_multiply(num, num, qr); if (l_ecc_scalar_legendre(num) == -1) {