Skip to content

Commit

Permalink
fix openldap crash when checkRDN=1 and username contains dash #16
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcoutadeur committed Aug 20, 2019
1 parent eb43ab5 commit ff79469
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ppm.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,23 +298,28 @@ containsRDN(char* passwd, char* DN)
{
if (strlen(token) > 2)
{
ppm_log(LOG_NOTICE, "ppm: Checking if %s part of RDN matches the password", token);
// Compile regular expression
reti = regcomp(&regex, token, REG_ICASE);
if (reti) {
ppm_log(LOG_ERR, "ppm: Cannot compile regex: %s", token);
exit(EXIT_FAILURE);
}
}

// Execute regular expression
reti = regexec(&regex, passwd, 0, NULL, 0);
if (!reti)
{
// Execute regular expression
reti = regexec(&regex, passwd, 0, NULL, 0);
if (!reti)
{
regfree(&regex);
return 1;
}

regfree(&regex);
return 1;
}

regfree(&regex);
else
{
ppm_log(LOG_NOTICE, "ppm: %s part of RDN is too short to be checked", token);
}
token = strtok(NULL, TOKENS_DELIMITERS);
}

Expand Down
1 change: 1 addition & 0 deletions unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ launch_test "ppm2.conf" "uid=test,ou=users,dc=my-domain,dc=com" "AAaaaBBBBaaa01A
# password in RDN
launch_test "ppm3.conf" "uid=User_Password10-test,ou=users,dc=my-domain,dc=com" "Password10" "FAIL"
launch_test "ppm3.conf" "uid=User_Passw0rd-test,ou=users,dc=my-domain,dc=com" "Password10" "PASS"
launch_test "ppm3.conf" "uid=User-Pw-Test,ou=users,dc=my-domain,dc=com" "Password10" "PASS"


echo "${RESULT} error(s) encountered"
Expand Down

0 comments on commit ff79469

Please sign in to comment.