Skip to content

Commit 9012799

Browse files
committed
Bluetooth: ipsp: Fix not checking return of build_reply
net_pkt_sendto uses size_t as parameter for len so the value would be treat as unsigned which may cause and invalid memory to be read. Fixes #14950 #14955 Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 9e81cbe commit 9012799

File tree

1 file changed

+8
-0
lines changed
  • samples/bluetooth/ipsp/src

1 file changed

+8
-0
lines changed

samples/bluetooth/ipsp/src/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ static void udp_received(struct net_context *context,
217217
set_dst_addr(family, pkt, ip_hdr->ipv6, proto_hdr->udp, &dst_addr);
218218

219219
ret = build_reply(dbg, pkt, buf_tx);
220+
if (ret < 0) {
221+
LOG_ERR("Cannot send data to peer (%d)", ret);
222+
return;
223+
}
220224

221225
net_pkt_unref(pkt);
222226

@@ -262,6 +266,10 @@ static void tcp_received(struct net_context *context,
262266
family == AF_INET6 ? '6' : '4');
263267

264268
ret = build_reply(dbg, pkt, buf_tx);
269+
if (ret < 0) {
270+
LOG_ERR("Cannot send data to peer (%d)", ret);
271+
return;
272+
}
265273

266274
net_pkt_unref(pkt);
267275

0 commit comments

Comments
 (0)