]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: Add test with == true or false to boolean if statements in ldb_dn_explode()
authorAndrew Bartlett <abartlet@samba.org>
Wed, 21 Aug 2019 23:09:55 +0000 (11:09 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 27 Aug 2019 04:44:41 +0000 (04:44 +0000)
This is beyond the normal level of clarity we expect in Samba, and is of course
rudundent, but this is a complex routine that has confusing tests, some of
pointers and some of boolean state values.

This tries to make the code as clear as possible pending a more comprehensive
rewrite.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/ldb/common/ldb_dn.c

index 377dd74d9f3596d033747ae2662b2b17b5a5d597..b9a414dc56661256ef10906486ec63133bd4fe05 100644 (file)
@@ -298,7 +298,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
        char *parse_dn;
        bool is_index;
 
-       if (dn == NULL || dn->invalid) {
+       if (dn == NULL || dn->invalid == true) {
                return false;
        }
 
@@ -324,7 +324,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
        }
 
        /* Special DNs case */
-       if (dn->special) {
+       if (dn->special == true) {
                return true;
        }
 
@@ -350,7 +350,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
        d = dt = data;
 
        while (*p) {
-               if (in_extended) {
+               if (in_extended == true) {
 
                        if (!in_ex_name && !in_ex_value) {
 
@@ -437,8 +437,8 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                        *d++ = *p++;
                        continue;
                }
-               if (in_attr) {
-                       if (trim) {
+               if (in_attr == true) {
+                       if (trim == true) {
                                if (*p == ' ') {
                                        p++;
                                        continue;
@@ -505,7 +505,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                                goto failed;
                        }
 
-                       if (is_oid && ( ! (isdigit(*p) || (*p == '.')))) {
+                       if (is_oid == true && ( ! (isdigit(*p) || (*p == '.')))) {
                                /* not a digit nor a dot,
                                 * invalid attribute oid */
                                ldb_dn_mark_invalid(dn);
@@ -521,8 +521,8 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                        continue;
                }
 
-               if (in_value) {
-                       if (in_quote) {
+               if (in_value == true) {
+                       if (in_quote == true) {
                                if (*p == '\"') {
                                        if (p[-1] != '\\') {
                                                p++;
@@ -535,7 +535,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                                continue;
                        }
 
-                       if (trim) {
+                       if (trim == true) {
                                if (*p == ' ') {
                                        p++;
                                        continue;
@@ -558,7 +558,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                        */
 
                        case ',':
-                               if (escape) {
+                               if (escape == true) {
                                        *d++ = *p++;
                                        l++;
                                        escape = false;
@@ -619,7 +619,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                                accept the base64 encoded binary index
                                values, which contain a '+' or '='
                                which should normally be escaped */
-                               if (is_index) {
+                               if (is_index == true) {
                                        if (t != NULL) {
                                                t = NULL;
                                        }
@@ -634,7 +634,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                        case '>':
                        case ';':
                                /* a string with not escaped specials is invalid (tested) */
-                               if ( ! escape) {
+                               if (escape == false) {
                                        ldb_dn_mark_invalid(dn);
                                        goto failed;
                                }
@@ -649,7 +649,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                                break;
 
                        case '\\':
-                               if ( ! escape) {
+                               if (escape == false) {
                                        escape = true;
                                        p++;
                                        continue;
@@ -665,7 +665,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                                break;
 
                        default:
-                               if (escape) {
+                               if (escape == true) {
                                        if (isxdigit(p[0]) && isxdigit(p[1])) {
                                                if (sscanf(p, "%02x", &x) != 1) {
                                                        /* invalid escaping sequence */
@@ -705,13 +705,13 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
                }
        }
 
-       if (in_attr || in_quote) {
+       if (in_attr == true || in_quote == true) {
                /* invalid dn */
                ldb_dn_mark_invalid(dn);
                goto failed;
        }
 
-       if (in_value) {
+       if (in_value == true) {
                /* save last element */
                if (t != NULL) {
                        /* trim back */