Always perform == or != operation on cmp function result
Although not required to address bad code generation in some versions of gcc 9 and 10, a coding style that requires explicit comparison of the result to zero before use is both clearer and would have avoided the generation of bad code. This change converts all use of cmp function usage from ``` if (strcmp(a, b) || !strcmp(c, d)) ... ``` to ``` if (strcmp(a, b) != 0 || strcmp(c, d)) == 0 ``` for all C library cmp functions and related: - strcmp(), strncmp() - strcasecmp(), strncasecmp() - stricmp(), strnicmp() - memcmp() Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
This commit is contained in:

committed by
Jeffrey Altman

parent
02200d55ea
commit
5f63215d0d
10
kdc/bx509d.c
10
kdc/bx509d.c
@@ -176,7 +176,7 @@ audit_trail(bx509_request_desc r, krb5_error_code ret)
|
||||
}
|
||||
|
||||
/* Let's save a few bytes */
|
||||
if (retname && !strncmp("KRB5KDC_", retname, sizeof("KRB5KDC_") - 1))
|
||||
if (retname && strncmp("KRB5KDC_", retname, sizeof("KRB5KDC_") - 1) == 0)
|
||||
retname += sizeof("KRB5KDC_") - 1;
|
||||
#undef PREFIX
|
||||
heim_audit_trail((heim_svc_req_desc)r, ret, retname);
|
||||
@@ -299,7 +299,7 @@ generate_key(hx509_context context,
|
||||
hx509_cert cert = NULL;
|
||||
int ret;
|
||||
|
||||
if (strcmp(gen_type, "rsa"))
|
||||
if (strcmp(gen_type, "rsa") != 0)
|
||||
errx(1, "Only RSA keys are supported at this time");
|
||||
|
||||
if (asprintf(fn, "PEM-FILE:%s/.%s_priv_key.pem",
|
||||
@@ -1569,8 +1569,8 @@ bnegotiate_get_target(struct bx509_request_desc *r)
|
||||
return bad_403(r, EACCES,
|
||||
"Redirect request without Referer header nor allowed");
|
||||
|
||||
if (strncmp(referer, "https://", sizeof("https://") - 1) ||
|
||||
strncmp(redir, "https://", sizeof("https://") - 1))
|
||||
if (strncmp(referer, "https://", sizeof("https://") - 1) != 0 ||
|
||||
strncmp(redir, "https://", sizeof("https://") - 1) != 0)
|
||||
return bad_403(r, EACCES,
|
||||
"Redirect requests permitted only for https referrers");
|
||||
|
||||
@@ -1590,7 +1590,7 @@ bnegotiate_get_target(struct bx509_request_desc *r)
|
||||
}
|
||||
|
||||
/* Both must match */
|
||||
if (strcasecmp(s1, s2)) {
|
||||
if (strcasecmp(s1, s2) != 0) {
|
||||
free(s2);
|
||||
free(s1);
|
||||
return bad_403(r, EACCES, "Redirect request does not match referer");
|
||||
|
Reference in New Issue
Block a user