From: Davin McCall Date: Mon, 23 Dec 2019 03:44:22 +0000 (+1000) Subject: query_name: always return with NAK if service handle invalid X-Git-Tag: v0.8.1~17 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ec5efd2cde040ff9c732cc078c767e950165f753;p=oweals%2Fdinit.git 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. --- 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;