From: Remi Gacogne Date: Tue, 22 Oct 2024 09:53:25 +0000 (+0200) Subject: dnsdist: Fix Coverity warning 445614: " Argument cannot be negative" X-Git-Tag: rec-5.2.0-alpha1~16^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F14792%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Fix Coverity warning 445614: " Argument cannot be negative" --- diff --git a/pdns/dnsdistdist/dnsdist-cache.cc b/pdns/dnsdistdist/dnsdist-cache.cc index 841e37a442..e3522a38e8 100644 --- a/pdns/dnsdistdist/dnsdist-cache.cc +++ b/pdns/dnsdistdist/dnsdist-cache.cc @@ -484,7 +484,11 @@ uint64_t DNSDistPacketCache::getEntriesCount() uint64_t DNSDistPacketCache::dump(int fileDesc, bool rawResponse) { - auto filePtr = pdns::UniqueFilePtr(fdopen(dup(fileDesc), "w")); + auto fileDescDuplicated = dup(fileDesc); + if (fileDescDuplicated < 0) { + return 0; + } + auto filePtr = pdns::UniqueFilePtr(fdopen(fileDescDuplicated, "w")); if (filePtr == nullptr) { return 0; }