-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coverity passkey fixes #7087
Coverity passkey fixes #7087
Conversation
6ed342d
to
a096f68
Compare
be7ceed
to
18e9143
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take my inline comments lightly. Generally speaking, I think there is something wrong and that is why things don't add up in my mind and why I provided several contradictory inline comments.
As a general comment, I think you should consider treating all cases (creds[0] and creds[i]) the same just by differentiating them when calling snprintf()
. Also, adding several unit tests for this function will help to detect memory related problems.
for (int i = 1; creds[i] != NULL; i++) { | ||
strcat(result_creds, ","); | ||
creds_len += strlen(creds[i]) + 1; | ||
rc = snprintf(result_creds, total_sz, "%s", creds[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the second argument should be creds_buf_len
and not total_sz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Fix for: CID 336599: Memory - corruptions (OVERRUN) Overrunning dynamic array "result_creds" by passing it to a function that accesses it at byte "creds_len".
Fix for: CID 470374: Resource leaks (RESOURCE_LEAK) Variable "prompt_reply" going out of scope leaks the storage it points to.
==367086== Conditional jump or move depends on uninitialised value(s) ==367086== at 0x12BF1A31: string_get (load.c:894) ==367086== by 0x12BF291D: stream_get.part.0 (load.c:158) ==367086== by 0x12BF3182: UnknownInlinedFun (load.c:154) ==367086== by 0x12BF3182: UnknownInlinedFun (load.c:227) ==367086== by 0x12BF3182: lex_scan.isra.0 (load.c:573) ==367086== by 0x12BF7F6A: parse_json (load.c:868) ==367086== by 0x12BF80C8: json_loads (load.c:920) ==367086== by 0x12BDDFD9: sss_passkey_message_from_reply_json (passkey_utils.c:544) ==367086== by 0x12BDCA76: sss_passkeycl_process (passkey_clpreauth.c:321) ==367086== by 0x4906215: UnknownInlinedFun (preauth2.c:352) ==367086== by 0x4906215: UnknownInlinedFun (preauth2.c:679) ==367086== by 0x4906215: k5_preauth (preauth2.c:1018) ==367086== by 0x48F9489: UnknownInlinedFun (get_in_tkt.c:1351) ==367086== by 0x48F9489: UnknownInlinedFun (get_in_tkt.c:1912) ==367086== by 0x48F9489: krb5_init_creds_step (get_in_tkt.c:1868) ==367086== by 0x48FA43A: k5_init_creds_get (get_in_tkt.c:564) ==367086== by 0x48FB3EB: k5_get_init_creds (get_in_tkt.c:1978) ==367086== by 0x48FB817: krb5_get_init_creds_password (gic_pwd.c:210)
18e9143
to
69d5bd2
Compare
Updated, please check the latest version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the patches.
Thank you, ACK. |
Pushed PR: #7087
|
Fixes for the below. I tested the fixes submitting a
scan.coverity.com
build with my fork and it fixes these 2 defects.