This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=af5c8d99e08c0e9bc5e929f56a2753fa0bc5d10c

commit af5c8d99e08c0e9bc5e929f56a2753fa0bc5d10c
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Wed Jul 10 22:38:16 2024 +0200

    libdpkg: Check for limit >= 0 instead of != -1 in buffer_copy()
    
    Make the check both more future proof against passing other negative
    values (which is what is triggering warnings in static analyzers), and
    match the recent coding style switch to check for all negative values
    instead of a specific -1 (although in this case this does not signal an
    error, but an unlimited copy).
    
    Warned-by: coverity
---
 lib/dpkg/buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c
index fbacb3e56..3d4ed9e6a 100644
--- a/lib/dpkg/buffer.c
+++ b/lib/dpkg/buffer.c
@@ -184,7 +184,7 @@ buffer_copy(struct buffer_data *read_data,
        off_t bytesread = 0, byteswritten = 0;
        off_t totalread = 0, totalwritten = 0;
 
-       if ((limit != -1) && (limit < bufsize))
+       if ((limit >= 0) && (limit < bufsize))
                bufsize = limit;
        if (bufsize == 0)
                buf = NULL;
@@ -202,7 +202,7 @@ buffer_copy(struct buffer_data *read_data,
 
                totalread += bytesread;
 
-               if (limit != -1) {
+               if (limit >= 0) {
                        limit -= bytesread;
                        if (limit < bufsize)
                                bufsize = limit;

-- 
Dpkg.Org's dpkg

Reply via email to