]> granicus.if.org Git - openssl/commitdiff
Fix ordering of compare functions: strncmp() must be used first, as it
authorLutz Jänicke <jaenicke@openssl.org>
Tue, 8 Apr 2003 06:28:34 +0000 (06:28 +0000)
committerLutz Jänicke <jaenicke@openssl.org>
Tue, 8 Apr 2003 06:28:34 +0000 (06:28 +0000)
the cipher name in the list is not guaranteed to be at least "buflen"
long.
PR: 567
Submitted by: "Matt Harren" <matth@cs.berkeley.edu>

ssl/ssl_ciph.c

index c72be89e9ae3a03662a968afaebc20c3204519fa..888b667fa12ce50f64b0f5e9680714c070c49576 100644 (file)
@@ -668,13 +668,14 @@ static int ssl_cipher_process_rulestr(const char *rule_str,
                         * So additionally check whether the cipher name found
                         * has the correct length. We can save a strlen() call:
                         * just checking for the '\0' at the right place is
-                        * sufficient, we have to strncmp() anyway.
+                        * sufficient, we have to strncmp() anyway. (We cannot
+                        * use strcmp(), because buf is not '\0' terminated.)
                         */
                         j = found = 0;
                         while (ca_list[j])
                                {
-                               if ((ca_list[j]->name[buflen] == '\0') &&
-                                   !strncmp(buf, ca_list[j]->name, buflen))
+                               if (!strncmp(buf, ca_list[j]->name, buflen) &&
+                                   (ca_list[j]->name[buflen] == '\0'))
                                        {
                                        found = 1;
                                        break;