fix basicauth string comparison

closes #160
This commit is contained in:
rofl0r 2018-03-28 02:02:45 +01:00 committed by rofl0r
parent ae0cbfe3f2
commit 0aad2f5b92

View File

@ -83,16 +83,15 @@ void basicauth_add (vector_t authlist,
int basicauth_check (vector_t authlist, const char *authstring) int basicauth_check (vector_t authlist, const char *authstring)
{ {
ssize_t vl, i; ssize_t vl, i;
size_t al, el; size_t el;
const char* entry; const char* entry;
vl = vector_length (authlist); vl = vector_length (authlist);
if (vl == -EINVAL) return 0; if (vl == -EINVAL) return 0;
al = strlen (authstring);
for (i = 0; i < vl; i++) { for (i = 0; i < vl; i++) {
entry = vector_getentry (authlist, i, &el); entry = vector_getentry (authlist, i, &el);
if (strncmp (authstring, entry, al) == 0) if (strcmp (authstring, entry) == 0)
return 1; return 1;
} }
return 0; return 0;