#48027 Root DN Access Control plugin needs improved config validation
Closed: Fixed None Opened 5 years ago by mreynolds.

The use of strcspn was not working properly for all the config validations. Also we should be returning errors if any of the config settings are invalid, instead of ignoring new the new values.


I think the problem with strcspn is that it is not being used correctly. If you want to see if a string consists of numbers and only numbers, use strspn instead of strcspn like this:
{{{
/ teststring must be properly null terminated /
size_t end = strspn(teststring, "0123456789");
if (end && (teststring[end] == '\0')) { / end is the index of the trailing \0 /
/ string consists of only numbers /
} else {
/ string has characters other than numbers in it /
}
}}}
Basically, use strspn when you want a string to have only the specified characters, and use strcspn when you want a string that has none of the specified characters.

Replying to [comment:2 rmeggins]:

I think the problem with strcspn is that it is not being used correctly.
Basically, use strspn when you want a string to have only the specified characters, and use strcspn when you want a string that has none of the specified characters.

Thanks for the insight! I was thrown off because strcspn was working when just dealing with numbers and letters, but it did not work with other characters. Using strspn() worked for all the cases.

New patch attached.

71901e8..53e3444 master -> master
commit 53e3444
Author: Mark Reynolds mreynolds@redhat.com
Date: Tue Feb 10 09:16:25 2015 -0500

a61c3cb..8dc210d 389-ds-base-1.3.3 -> 389-ds-base-1.3.3
commit 8dc210d

4488604..7944ed5 389-ds-base-1.3.2 -> 389-ds-base-1.3.2
commit 7944ed5

ddcab8a..1508e72 389-ds-base-1.3.1 -> 389-ds-base-1.3.1
commit 1508e7270c85e83542130757138a6bcb97f75b95

42c3ced..dd864ce 389-ds-base-1.2.11 -> 389-ds-base-1.2.11
commit dd864ce

Metadata Update from @mreynolds:
- Issue assigned to mreynolds
- Issue set to the milestone: 1.2.11.33

3 years ago

Login to comment on this ticket.

Metadata