Skip to content

Commit

Permalink
rr_decode: Don't accept offsets pointing to the current element
Browse files Browse the repository at this point in the history
  • Loading branch information
chouquette committed Mar 19, 2020
1 parent f9055ad commit 0103f40
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rr.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ static const uint8_t *
rr_decode(const uint8_t *ptr, size_t *n, const uint8_t *root, char **ss)
{
char *s;
const uint8_t *orig_ptr = ptr;

s = *ss = malloc(MDNS_DN_MAXSZ);
if (!s)
Expand Down Expand Up @@ -321,6 +322,9 @@ rr_decode(const uint8_t *ptr, size_t *n, const uint8_t *root, char **ss)

p = root + len;
m = ptr - p + *n;
/* Avoid recursing on the same element */
if (p == orig_ptr)
goto err;
rr_decode(p, &m, root, &buf);
if (free_space <= strlen(buf)) {
free(buf);
Expand Down

0 comments on commit 0103f40

Please sign in to comment.