Skip to content

Commit

Permalink
Merge pull request #214 from BIIIANG/master
Browse files Browse the repository at this point in the history
stun: add checks for attribute length before read from it
  • Loading branch information
andywolk committed May 12, 2023
2 parents 3f17604 + c3bbc50 commit 3ce1046
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libsofia-sip-ua/stun/stun_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ int stun_parse_attr_error_code(stun_attr_t *attr, const unsigned char *p, unsign
uint32_t tmp;
stun_attr_errorcode_t *error;

if (len < 4) {
return -1;
}

memcpy(&tmp, p, sizeof(uint32_t));
tmp = ntohl(tmp);
error = (stun_attr_errorcode_t *) malloc(sizeof(*error));
Expand All @@ -271,6 +275,11 @@ int stun_parse_attr_uint32(stun_attr_t *attr, const unsigned char *p, unsigned l
{
uint32_t tmp;
stun_attr_changerequest_t *cr;

if (len < 4) {
return -1;
}

cr = (stun_attr_changerequest_t *) malloc(sizeof(*cr));
memcpy(&tmp, p, sizeof(uint32_t));
cr->value = ntohl(tmp);
Expand Down

0 comments on commit 3ce1046

Please sign in to comment.