From bc129a26a8553a073ed16c1253a12801c16fc96b Mon Sep 17 00:00:00 2001 From: jfreegman Date: Sat, 2 Apr 2022 10:44:39 -0400 Subject: [PATCH] Fix possible buffer overread --- toxcore/group_announce.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/toxcore/group_announce.c b/toxcore/group_announce.c index 50867fce746..903d906d3e7 100644 --- a/toxcore/group_announce.c +++ b/toxcore/group_announce.c @@ -191,6 +191,10 @@ static int gca_unpack_announce(const Logger *log, const uint8_t *data, uint16_t } if (announce->ip_port_is_set) { + if (length == 0) { + return -1; + } + const int ip_port_length = unpack_ip_port(&announce->ip_port, data + offset, length - offset, false); if (ip_port_length == -1) {