Conversation
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com>
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com>
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com>
Resolves: SSSD#5905 Reviewed-by: Alexey Tikhonov <atikhono@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the smart card handling logic in p11_child_openssl.c by extracting slot-specific operations into a new do_slot function. This change enables support for processing multiple smart card tokens, an improvement over the previous implementation that only handled the first token found. While the refactoring is a good step forward, I've identified two critical vulnerabilities where strcmp is called with a potentially NULL argument, which could lead to a segmentation fault. These issues must be addressed by adding appropriate NULL checks.
| token_name, slot_name, (int) slot_id, (int) module_id, | ||
| module_file_name); | ||
|
|
||
| if (mode == OP_AUTH && strcmp(token_name, token_name_in) != 0) { |
There was a problem hiding this comment.
The strcmp call can cause a segmentation fault if token_name_in is NULL. The token_name_in parameter can be NULL if it's not provided on the command line when invoking p11_child. You should add a NULL check for token_name_in before calling strcmp.
if (mode == OP_AUTH && token_name_in != NULL && strcmp(token_name, token_name_in) != 0) {| free(mod_name); | ||
|
|
||
| DEBUG(SSSDBG_TRACE_ALL, "dll name: [%s].\n", mod_file_name); | ||
| if (mode == OP_AUTH && strcmp(mod_file_name, module_name_in) != 0) { |
There was a problem hiding this comment.
The strcmp call can cause a segmentation fault if module_name_in is NULL. The module_name_in parameter can be NULL if it's not provided on the command line when invoking p11_child. You should add a NULL check for module_name_in before calling strcmp.
if (mode == OP_AUTH && module_name_in != NULL && strcmp(mod_file_name, module_name_in) != 0) {Use a separate `const char *dot` variable for the strchr() result on the const input string, keeping the mutable `char *p` for the later iteration over the output buffer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make rid1 and rid2 `const char *` since they only hold strrchr() results from const input strings and are used for pointer arithmetic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make endptr and end_range `const char *` since they only hold strchr()/strrchr() results from const input strings. Introduce a separate `numendptr` variable for the strtouint32() output parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45b5a46 to
6760a73
Compare
Make sep `const char *` since it only holds a strchr() result from a const input string and is used for pointer arithmetic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make specdelim and kwdelim `const char *` in parse_sub_filter() and parse_filter() since they only hold strchr() results from const input strings and are used for pointer arithmetic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make delim in get_type_prefix() and sep in expand_sid() `const char *` since they only hold strchr()/strrchr() results from const input strings and are used for pointer arithmetic and reading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace will_return_always with will_return_uint_always, will_return_count with will_return_uint_count, and assert_in_range with assert_uint_in_range. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use will_return_ptr_always instead of will_return_always in the will_return_nl_cache_foreach_always wrapper macro since the value passed is a pointer, not an integer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1db7277 to
ffc71d3
Compare
Use will_return_uint_count instead of will_return_count in the sss_will_return_always wrapper macro in common_mock.h. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use will_return_ptr_always instead of will_return_always in set_entry_parse() since the value passed is a pointer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace will_return_always with will_return_ptr_always for pointer arguments and will_return_uint_always for integer arguments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make at_sign `const char *` since it only holds a strchr() result from a const input string and is used for reading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add explicit dependency so that install-sssdlibLTLIBRARIES waits for install-pkglibLTLIBRARIES to complete. Without this, make -jN install can fail because libtool tries to relink sssdlib plugins (e.g. libsss_simple.la) before their pkglib dependencies (e.g. libsss_util.la) are installed, causing "cannot find -lsss_util". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
No description provided.