Skip to content

Commit

Permalink
Merge pull request #10366 from crest42/gnrc_udp_use_after_free
Browse files Browse the repository at this point in the history
gnrc_sock_[udp|ip]: read return value for _recv after release
  • Loading branch information
miri64 committed Nov 12, 2018
2 parents 0319a56 + e904706 commit 685efc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sys/net/gnrc/sock/ip/gnrc_sock_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ ssize_t sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len,
return -EPROTO;
}
memcpy(data, pkt->data, pkt->size);
res = (int)pkt->size;
gnrc_pktbuf_release(pkt);
return (int)pkt->size;
return res;
}

ssize_t sock_ip_send(sock_ip_t *sock, const void *data, size_t len,
Expand Down
3 changes: 2 additions & 1 deletion sys/net/gnrc/sock/udp/gnrc_sock_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ ssize_t sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len,
return -EPROTO;
}
memcpy(data, pkt->data, pkt->size);
res = (int)pkt->size;
gnrc_pktbuf_release(pkt);
return (int)pkt->size;
return res;
}

ssize_t sock_udp_send(sock_udp_t *sock, const void *data, size_t len,
Expand Down

0 comments on commit 685efc4

Please sign in to comment.