lib: make the reader comparison case-insensitive
sadly strcasestr is a GNU/BSD extension, not part of posix so we have to do our own thing here or do different things on different platforms.
This commit is contained in:
+13
-1
@@ -349,7 +349,19 @@ ykpiv_rc ykpiv_connect(ykpiv_state *state, const char *wanted) {
|
|||||||
|
|
||||||
for(reader_ptr = reader_buf; *reader_ptr != '\0'; reader_ptr += strlen(reader_ptr) + 1) {
|
for(reader_ptr = reader_buf; *reader_ptr != '\0'; reader_ptr += strlen(reader_ptr) + 1) {
|
||||||
if(wanted) {
|
if(wanted) {
|
||||||
if(!strstr(reader_ptr, wanted)) {
|
char *ptr = reader_ptr;
|
||||||
|
bool found = false;
|
||||||
|
do {
|
||||||
|
if(strlen(ptr) < strlen(wanted)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(strncasecmp(ptr, wanted, strlen(wanted)) == 0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while(*ptr++);
|
||||||
|
|
||||||
|
if(found == false) {
|
||||||
if(state->verbose) {
|
if(state->verbose) {
|
||||||
fprintf(stderr, "skipping reader '%s' since it doesn't match '%s'.\n", reader_ptr, wanted);
|
fprintf(stderr, "skipping reader '%s' since it doesn't match '%s'.\n", reader_ptr, wanted);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user