Skip to content
This repository has been archived by the owner on Oct 11, 2018. It is now read-only.

Commit

Permalink
Added check to ensure we're not matching zero length strings
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaubergine committed Oct 22, 2015
1 parent c441216 commit 575977e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/authy_api.c
Expand Up @@ -177,7 +177,9 @@ tokenResponseIsValid(char *pszResponse)
shouldn't be the last one because it won't be a key */
for (cnt = 0; cnt < 19; cnt++)
{
if(strncmp(pszResponse + (tokens[cnt]).start, "token", (tokens[cnt]).end - (tokens[cnt]).start) == 0)
/* avoid matching empty strings since "" == "" */
int len = (tokens[cnt]).end - (tokens[cnt]).start;
if(len > 0 && strncmp(pszResponse + (tokens[cnt]).start, "token", len) == 0)
{
if(strncmp(pszResponse + (tokens[cnt+1]).start, "is valid", (tokens[cnt+1]).end - (tokens[cnt+1]).start) == 0){
return TRUE;
Expand Down

0 comments on commit 575977e

Please sign in to comment.