dbwrap: Adapt tdb_data_buf's overflow handling to modern conventions
authorVolker Lendecke <vl@samba.org>
Fri, 3 May 2019 13:43:35 +0000 (15:43 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 8 May 2019 16:33:25 +0000 (16:33 +0000)
This is the way we do it right now, avoid confusion why "tmp" might be
needed

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/dbwrap/dbwrap.c

index ff6c9224905fbdc3af85d9d72a4058afe28fa888..5e307ee47cd8feecc221b2710234c8cf3853ba30 100644 (file)
@@ -634,14 +634,12 @@ static ssize_t tdb_data_buf(const TDB_DATA *dbufs, int num_dbufs,
 
        for (i=0; i<num_dbufs; i++) {
                size_t thislen = dbufs[i].dsize;
-               size_t tmp;
 
-               tmp = needed + thislen;
-               if (tmp < needed) {
+               needed += thislen;
+               if (needed < thislen) {
                        /* wrap */
                        return -1;
                }
-               needed = tmp;
 
                if ((thislen != 0) && (needed <= buflen)) {
                        memcpy(p, dbufs[i].dptr, thislen);