]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
libtommath: Fix check mp_init_multi() result
authorMaks Naumov <maksqwe1@ukr.net>
Sat, 2 May 2015 20:21:37 +0000 (23:21 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 3 May 2015 13:53:59 +0000 (16:53 +0300)
If the mp_init_multi() call had failed due to memory allocation failure,
mp_div() would have returned 1 instead of MP_MEM (-2). It looks like all
callers are checking the return value against MP_OKAY instead of <1
(etc.), so this does not seem to result in difference in behavior.
Anyway, it's best to fix the mp_div() return value for the MP_MEM error
case to avoid unexpected behavior.

Signed-off-by: Maks Naumov <maksqwe1@ukr.net>
src/tls/libtommath.c

index 3fb8fbed25e78b780ebd2f6a9469b8d486ac627e..251133e711285a6894fc4c9cc30e31bbc723c676 100644 (file)
@@ -1631,7 +1631,7 @@ static int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   }
        
   /* init our temps */
-  if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL) != MP_OKAY)) {
+  if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL)) != MP_OKAY) {
      return res;
   }