Remove -Wmaybe-uninitialized warning in pkix_pl_ldapdefaultclient.c
Categories
(NSS :: Build, defect, P2)
Tracking
(Not tracked)
People
(Reporter: giulio.benetti, Assigned: giulio.benetti)
Details
Attachments
(1 file, 1 obsolete file)
|
1.54 KB,
patch
|
marcus.apb
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Steps to reproduce:
Build with:
make nss_build_all BUILD_OPT=1 ALLOW_OPT_CODE_SIZE=1 OPT_CODE_SIZE=1
Actual results:
pkix_pl_ldapdefaultclient.c:376:21: error: ‘*((void )&msg+32).resultCode.data’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
if ((ldapBindResponse->resultCode.data) == SUCCESS) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Expected results:
No warning.
| Assignee | ||
Comment 1•7 years ago
|
||
This patch fixes the warning.
Updated•7 years ago
|
Updated•7 years ago
|
Comment 2•7 years ago
|
||
Comment 3•7 years ago
•
|
||
Updated•7 years ago
|
| Assignee | ||
Comment 4•7 years ago
|
||
Hi Marcus,
IMHO I'm not always overriding value received from msg.protocolOp.op.bindResponseMsg, I'm only pointing to it.
Then, before calling:
PKIX_CHECK(pkix_pl_LdapDefaultClient_DecodeBindResponse
(client->arena, &decode, &msg, &rv, plContext),
PKIX_LDAPDEFAULTCLIENTDECODEBINDRESPONSEFAILED);
I set:
ldapBindResponse->resultCode.data = NULL;
so if pkix_pl_LdapDefaultClient_DecodeBindResponse() changes or not "ldapBindResponse->resultCode.data" it should be ok.
What you're suggesting is not possible due to null-pointer dereferencing when:
LDAPBindResponse *ldapBindResponse = NULL;
ldapBindResponse->resultCode.data = NULL;
But I can move:
ldapBindResponse->resultCode.data = NULL;
right after:
LDAPBindResponse *ldapBindResponse = &msg.protocolOp.op.bindResponseMsg;
and this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ is only a way to short this:
ldapBindResponse->resultCode.data = NULL;
Best regards
Comment 5•7 years ago
|
||
Hi Giulio,
Yes, this is the point. : )
Move ldapBindResponse->resultCode.data = NULL right after LDAPBindResponse *ldapBindResponse = &msg.protocolOp.op.bindResponseMsg;
This is enough.
Could you update the patch, please?
Thanks,
| Assignee | ||
Comment 6•7 years ago
|
||
Here is the requested patch.
Comment 7•7 years ago
|
||
Updated•7 years ago
|
Comment 8•7 years ago
|
||
Description
•