9169 libsldap: comparison between pointer and zero character constant
Review Request #896 — Created Feb. 22, 2018 and submitted
Information | |
---|---|
tsoome | |
illumos-gate | |
9169 | |
6ba0443... | |
Reviewers | |
general | |
../common/ns_crypt.c:101:19: error: comparison between pointer and zero character constant [-Werror=pointer-compare] if (++anHexaStr != '\0') { ^~ ../common/ns_crypt.c:101:7: note: did you mean to dereference the pointer? if (++anHexaStr != '\0') { ^~ ../common/ns_writes.c: In function '__s_cvt_hosts': ../common/ns_writes.c:2035:54: error: comparison between pointer and zero character constant [-Werror=pointer-compare] ptr->h_addr_list == NULL || ptr->h_addr_list[0] == '\0') { ^~ ../common/ns_writes.c:2035:34: note: did you mean to dereference the pointer? ptr->h_addr_list == NULL || ptr->h_addr_list[0] == '\0') { ^ ../common/ns_writes.c: In function '__s_cvt_services': ../common/ns_writes.c:2347:61: error: comparison between pointer and zero character constant [-Werror=pointer-compare] if (ptr->s_name == NULL || ptr->s_port < 0 || ptr->s_proto == '\0') { ^~ ../common/ns_writes.c:2347:48: note: did you mean to dereference the pointer? if (ptr->s_name == NULL || ptr->s_port < 0 || ptr->s_proto == '\0') { ^ ../common/ns_writes.c: In function '__s_cvt_netmasks': ../common/ns_writes.c:2561:19: error: comparison between pointer and zero character constant [-Werror=pointer-compare] if (ptr->netmask != '\0') { ^~ ../common/ns_writes.c:2561:6: note: did you mean to dereference the pointer? if (ptr->netmask != '\0') { ^ ../common/ns_writes.c: In function '__s_cvt_netgroups': ../common/ns_writes.c:2619:16: error: comparison between pointer and zero character constant [-Werror=pointer-compare] if (ptr->name != '\0') { ^~ ../common/ns_writes.c:2619:6: note: did you mean to dereference the pointer? if (ptr->name != '\0') { ^ ../common/ns_writes.c: In function '__s_cvt_bootparams': ../common/ns_writes.c:2718:16: error: comparison between pointer and zero character constant [-Werror=pointer-compare] if (ptr->name != '\0') { ^~ ../common/ns_writes.c:2718:6: note: did you mean to dereference the pointer? if (ptr->name != '\0') { ^ ../common/ns_writes.c: In function '__s_cvt_ethers': ../common/ns_writes.c:2782:38: error: comparison between pointer and zero character constant [-Werror=pointer-compare] if (ptr->name == NULL || ptr->ether == '\0') { ^~ ../common/ns_writes.c:2782:27: note: did you mean to dereference the pointer? if (ptr->name == NULL || ptr->ether == '\0') { ^ cc1: all warnings being treated as errors
Change Summary:
ok there is some confusion about what has to be checked and protected.
So, first of all, we perform updates by calling __s_add_attr() while we provide strings as attribute name and value. s_add_attr() does call strdup() which will call strlen() which will crash us if NULL pointer is passed — therefore it is essential to prevent NULL pointers being passed.
Now the empty strings are a bit different story - we may want to create (attribute, value) pairs with empty string as a value - for example, when we want to make sure the attribute itself is there, even if not populated.
We also can not have empty names, or we will get empty value for “cn” attribute, and this can not happen.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+34 -40) |
Change Summary:
cstyle cleanup.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+74 -80) |
-
-
usr/src/lib/libsldap/common/ns_writes.c (Diff revision 3) Seeing all these needless indentation changes in reviews (wasting my reviewer time) still annoys me...
There is absolutely nothing wrong with a tab here.
Grumble!
Change Summary:
missing ||
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+74 -80) |
Change Summary:
few white space nits
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+83 -89) |
-
-
usr/src/lib/libsldap/common/ns_writes.c (Diff revision 5) I guess here was missing dereference, but you imporoved it and move this check to the line 3016 (after).
Do you think it was by design to add non empty alias ? I am asking because before-patch it is allowed, but after patch behaviour is changed.If you are sure, feel free drop Issue.