From ec5efd2cde040ff9c732cc078c767e950165f753 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Mon, 23 Dec 2019 13:44:22 +1000 Subject: [PATCH] query_name: always return with NAK if service handle invalid Existing code looks like a copy-pasto: returns ACK (not NAK?) and falls through to a potential null-pointer dereference if the service handle can't be found. --- src/control.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/control.cc b/src/control.cc index f9354c5..ec8217d 100644 --- a/src/control.cc +++ b/src/control.cc @@ -755,8 +755,8 @@ bool control_conn_t::process_query_name() service_record *service = find_service_for_key(handle); if (service == nullptr || service->get_name().length() > std::numeric_limits::max()) { - char ack_rep[] = { DINIT_RP_ACK }; - if (! queue_packet(ack_rep, 1)) return false; + char nak_rep[] = { DINIT_RP_NAK }; + return queue_packet(nak_rep, 1); } std::vector reply; -- 2.25.1