From: Remi Gacogne Date: Wed, 25 Sep 2024 13:12:09 +0000 (+0200) Subject: dnsdist: Apply Otto's suggestion to the Lua FFI proxy protocol API X-Git-Tag: dnsdist-1.9.7~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14716%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Apply Otto's suggestion to the Lua FFI proxy protocol API (cherry picked from commit 70530852d01f6c96606ff6d27c9487238c2cf95c) --- diff --git a/pdns/dnsdistdist/dnsdist-lua-ffi.cc b/pdns/dnsdistdist/dnsdist-lua-ffi.cc index 723fda4e75..f2af6c19f0 100644 --- a/pdns/dnsdistdist/dnsdist-lua-ffi.cc +++ b/pdns/dnsdistdist/dnsdist-lua-ffi.cc @@ -1112,9 +1112,12 @@ bool dnsdist_ffi_dnsquestion_add_proxy_protocol_values(dnsdist_ffi_dnsquestion_t size_t dnsdist_ffi_dnsquestion_get_proxy_protocol_values(dnsdist_ffi_dnsquestion_t* dnsQuestion, const dnsdist_ffi_proxy_protocol_value_t** out) { - size_t count = 0; - if (dnsQuestion == nullptr || dnsQuestion->dq == nullptr || out == nullptr || !dnsQuestion->dq->proxyProtocolValues) { - return count; + if (dnsQuestion == nullptr || dnsQuestion->dq == nullptr || !dnsQuestion->dq->proxyProtocolValues) { + return 0; + } + + if (out == nullptr) { + return dnsQuestion->proxyProtocolValuesVect->size(); } dnsQuestion->proxyProtocolValuesVect = std::make_unique>(dnsQuestion->dq->proxyProtocolValues->size()); @@ -1124,11 +1127,10 @@ size_t dnsdist_ffi_dnsquestion_get_proxy_protocol_values(dnsdist_ffi_dnsquestion targetEntry.size = entry.content.size(); targetEntry.value = entry.content.data(); targetEntry.type = entry.type; - ++count; } *out = dnsQuestion->proxyProtocolValuesVect->data(); - return count; + return dnsQuestion->proxyProtocolValuesVect->size(); } struct dnsdist_ffi_domain_list_t