Files
Open_Ultra_SAST/benchmarks/pairs/vfc/openssl-cve-2021-3712-ia5ncasecmp/fixed.c
T

37 lines
1001 B
C
Raw Normal View History

/* Provenance: openssl/openssl ia5ncasecmp (fixed).
* repo: openssl/openssl
* commit: d2015a783e64613d8e4a142fa05048d1863df944
* parent: 918430ba80d94ec8f05383b43b1872b1ebb13e1a
* commit_url: https://github.com/openssl/openssl/commit/d2015a783e64613d8e4a142fa05048d1863df944
* cve: CVE-2021-3712
* license: OpenSSL License
* function: ia5ncasecmp
* relpath: crypto/x509/v3_ncons.c
*/
static int ia5ncasecmp(const char *s1, const char *s2, size_t n)
{
for (; n > 0; n--, s1++, s2++) {
if (*s1 != *s2) {
unsigned char c1 = (unsigned char)*s1, c2 = (unsigned char)*s2;
/* Convert to lower case */
if (c1 >= 0x41 /* A */ && c1 <= 0x5A /* Z */)
c1 += 0x20;
if (c2 >= 0x41 /* A */ && c2 <= 0x5A /* Z */)
c2 += 0x20;
if (c1 == c2)
continue;
if (c1 < c2)
return -1;
/* c1 > c2 */
return 1;
}
}
return 0;
}