base64: remove a timing variation

This commit is contained in:
John Hood
2015-10-20 02:39:36 -04:00
parent 0eb614809a
commit 0de4082e86
+7 -2
View File
@@ -45,8 +45,13 @@ static unsigned char base64_char_to_sixbit(char c)
* Yes, this is slow. But it's also very simple, and easy to verify.
* We don't need performance here.
*/
const char *match = strchr(table, c);
if (!match) {
const char *match = NULL;
for ( const char *search = table; *search; search++ ) {
if ( *search == c ) {
match = search;
}
}
if ( !match ) {
return 0xff;
}
return match - table;