s3:glock: Move sanity check in g_lock_parse()
authorAndreas Schneider <asn@samba.org>
Thu, 26 Oct 2017 07:43:56 +0000 (09:43 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 9 Dec 2017 23:46:26 +0000 (00:46 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sun Dec 10 00:46:26 CET 2017 on sn-devel-144

source3/lib/g_lock.c

index c5d66e3855e8a0940c3635873cc29d4b12d905e4..50ea56634ba00266872fb909b2ac748acf5039fa 100644 (file)
@@ -74,12 +74,12 @@ static bool g_lock_parse(uint8_t *buf, size_t buflen, struct g_lock *lck)
 
        found_recs = IVAL(buf, 0);
 
+       buf += sizeof(uint32_t);
+       buflen -= sizeof(uint32_t);
        if (found_recs > buflen/G_LOCK_REC_LENGTH) {
                return false;
        }
 
-       buf += sizeof(uint32_t);
-       buflen -= sizeof(uint32_t);
        data_ofs = found_recs * G_LOCK_REC_LENGTH;
 
        *lck = (struct g_lock) {