Skip to content

Commit

Permalink
lib/command.c: fix leak id'ed by valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
louberger committed Dec 19, 2016
1 parent 74f361a commit e2c4c42
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ cmd_ipv6_prefix_match (const char *str)
const char *delim = "/\0";
char *dupe, *prefix, *mask, *context, *endptr;
int nmask = -1;
enum match_type ret;

if (str == NULL)
return partly_match;
Expand All @@ -1079,21 +1080,26 @@ cmd_ipv6_prefix_match (const char *str)
prefix = strtok_r(dupe, delim, &context);
mask = strtok_r(NULL, delim, &context);

ret = exact_match;
if (!mask)
return partly_match;

/* validate prefix */
if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1)
return no_match;

/* validate mask */
nmask = strtol (mask, &endptr, 10);
if (*endptr != '\0' || nmask < 0 || nmask > 128)
return no_match;
ret = partly_match;
else
{
/* validate prefix */
if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1)
ret = no_match;
else
{
/* validate mask */
nmask = strtol (mask, &endptr, 10);
if (*endptr != '\0' || nmask < 0 || nmask > 128)
ret = no_match;
}
}

XFREE(MTYPE_TMP, dupe);

return exact_match;
return ret;
}

#endif /* HAVE_IPV6 */
Expand Down

0 comments on commit e2c4c42

Please sign in to comment.