Commit c0b9321407d99eedbdd52a75bbd19491ae432fff
1 parent
ea4452de
the stack overflow issue was related to a not correctly initialized external var…
…iable (size). Use a ternery to prevent to large size values.
Showing
1 changed file
with
2 additions
and
5 deletions
@@ -51,12 +51,11 @@ static | @@ -51,12 +51,11 @@ static | ||
51 | TR_RemoteData | 51 | TR_RemoteData |
52 | udpSocketRecv(TR_Socket this, size_t size) | 52 | udpSocketRecv(TR_Socket this, size_t size) |
53 | { | 53 | { |
54 | - unsigned char * buffer = TR_malloc(size); | 54 | + unsigned char buffer[size>8192 ? 8192 : size]; |
55 | ssize_t received; | 55 | ssize_t received; |
56 | TR_RemoteData rdata; | 56 | TR_RemoteData rdata; |
57 | - TR_Socket remote; | 57 | + TR_Socket remote = TR_new(TR_UdpSocket, this->log, NULL, 0, 0); |
58 | 58 | ||
59 | - remote = TR_new(TR_UdpSocket, this->log, NULL, 0, 0); | ||
60 | remote->addrlen = this->addrlen; | 59 | remote->addrlen = this->addrlen; |
61 | 60 | ||
62 | received = recvfrom( | 61 | received = recvfrom( |
@@ -73,8 +72,6 @@ udpSocketRecv(TR_Socket this, size_t size) | @@ -73,8 +72,6 @@ udpSocketRecv(TR_Socket this, size_t size) | ||
73 | rdata = TR_new(TR_RemoteData, buffer, received, remote); | 72 | rdata = TR_new(TR_RemoteData, buffer, received, remote); |
74 | } | 73 | } |
75 | 74 | ||
76 | - TR_MEM_FREE(buffer); | ||
77 | - | ||
78 | rdata->free_remote = 1; | 75 | rdata->free_remote = 1; |
79 | 76 | ||
80 | return rdata; | 77 | return rdata; |
Please
register
or
login
to post a comment