Clean up a series of ifs, remove redundant processing.
authorJuho Vähä-Herttua <juhovh@iki.fi>
Wed, 26 Feb 2014 10:07:52 +0000 (12:07 +0200)
committerJuho Vähä-Herttua <juhovh@iki.fi>
Wed, 26 Feb 2014 10:07:52 +0000 (12:07 +0200)
Also add brackets, we do not want to make the same kind of mistake
Apple did with their SSL goto bug.

src/lib/digest.c

index 22912157c4c3c777b5d79c49f052384353f4f3bb..58c857835d96ae36570cb5cba90a81153599f629 100644 (file)
@@ -128,16 +128,17 @@ digest_is_valid(const char *our_realm, const char *password,
                else *last = '\0';
 
                /* Store value if it is relevant */
-               if (!strncmp("username=\"", first, 10))
+               if (!strncmp("username=\"", first, 10)) {
                        username = first+10;
-               if (!strncmp("realm=\"", first, 7))
+               } else if (!strncmp("realm=\"", first, 7)) {
                        realm = first+7;
-               if (!strncmp("nonce=\"", first, 7))
+               } else if (!strncmp("nonce=\"", first, 7)) {
                        nonce = first+7;
-               if (!strncmp("uri=\"", first, 5))
+               } else if (!strncmp("uri=\"", first, 5)) {
                        uri = first+5;
-               if (!strncmp("response=\"", first, 10))
+               } else if (!strncmp("response=\"", first, 10)) {
                        response = first+10;
+               }
        }
 
        if (!username || !realm || !nonce || !uri || !response) {