Skip to content

Commit

Permalink
Fix duplicate detection logic by ensuring exact match on string length (
Browse files Browse the repository at this point in the history
#6333)

Fix single valued parameters configuration code that accepts multiple comma separated values .
Updated the condition for checking duplicates to ensure that the lengths of the candidate and original strings are equal. This prevents false positives by confirming that the strings are identical at the start and match in length, enforcing an exact duplicate check.
  • Loading branch information
PavlNekrasov committed Sep 23, 2024
1 parent a82d9f0 commit cbb9e0e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ldap/servers/slapd/charray.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ slapi_str2charray_ext(char *str, char *brkstr, int allow_dups)
/* Always copy the first value into the array */
if ((!allow_dups) && (i != 0)) {
/* Check for duplicates */
size_t len_s = strlen(s);
for (j = 0; j < i; j++) {
if (strncmp(res[j], s, strlen(s)) == 0) {
if (len_s == strlen(res[j]) && strncmp(res[j], s, len_s) == 0) {
dup_found = 1;
break;
}
Expand Down

0 comments on commit cbb9e0e

Please sign in to comment.