]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ms_funcs: Merge similar return cases
authorJouni Malinen <j@w1.fi>
Mon, 29 Jun 2015 17:55:20 +0000 (20:55 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 29 Jun 2015 20:23:56 +0000 (23:23 +0300)
There is no need to have separate return statements for these corner
cases that are unlikely to be hit in practice.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/crypto/ms_funcs.c

index 5f57656038fe8405a4ef25d9b6a078278e4b90d0..a76e0185794ff0381d36c1e15c16ed088f457fdd 100644 (file)
@@ -174,9 +174,8 @@ int generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge,
        u8 password_hash[16];
 
        if (challenge_hash(peer_challenge, auth_challenge, username,
-                          username_len, challenge))
-               return -1;
-       if (nt_password_hash(password, password_len, password_hash))
+                          username_len, challenge) ||
+           nt_password_hash(password, password_len, password_hash))
                return -1;
        challenge_response(challenge, password_hash, response);
        return 0;
@@ -256,12 +255,9 @@ int generate_authenticator_response_pwhash(
        addr2[1] = challenge;
        addr2[2] = magic2;
 
-       if (hash_nt_password_hash(password_hash, password_hash_hash))
-               return -1;
-       if (sha1_vector(3, addr1, len1, response))
-               return -1;
-
-       if (challenge_hash(peer_challenge, auth_challenge, username,
+       if (hash_nt_password_hash(password_hash, password_hash_hash) ||
+           sha1_vector(3, addr1, len1, response) ||
+           challenge_hash(peer_challenge, auth_challenge, username,
                           username_len, challenge))
                return -1;
        return sha1_vector(3, addr2, len2, response);
@@ -435,10 +431,8 @@ int encrypt_pw_block_with_password_hash(
 
        os_memset(pw_block, 0, PWBLOCK_LEN);
 
-       if (utf8_to_ucs2(password, password_len, pw_block, 512, &ucs2_len) < 0)
-               return -1;
-
-       if (ucs2_len > 256)
+       if (utf8_to_ucs2(password, password_len, pw_block, 512, &ucs2_len) < 0
+           || ucs2_len > 256)
                return -1;
 
        offset = (256 - ucs2_len) * 2;