]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tdb: Fix parse_hex during `tdbtool storehex`
authorLin Liu <lin.liu01@cloud.com>
Tue, 18 Nov 2025 05:50:55 +0000 (05:50 +0000)
committerJennifer Sutton <jsutton@samba.org>
Thu, 20 Nov 2025 22:29:03 +0000 (22:29 +0000)
Fixes: fd0561279
During `tdbtool storehex`, tdbtool check whether the input
string in hex format.

However, during the check, the index is never moved forward,
resulting in checking beyond the valid input string.

This patch fix the issue by checking the valid string

Signed-off-by: Lin Liu <lin.liu01@citrix.com>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Jennifer Sutton <jsutton@samba.org>
Autobuild-Date(master): Thu Nov 20 22:29:03 UTC 2025 on atb-devel-224

lib/tdb/tools/tdbtool.c

index ecd1bb9b50b08517989b7643bcaee09af1d50962..6fcadcaa0f59444e2a28b8ae3f0b157ad72506d1 100644 (file)
@@ -363,13 +363,13 @@ static int store_tdb(char *keyname, size_t keylen, char* data, size_t datalen)
 
 static bool parse_hex(const char *src, size_t srclen, uint8_t *dst)
 {
-       size_t i=0;
+       const char *end = src + srclen;
 
        if ((srclen % 2) != 0) {
                return false;
        }
 
-       while (i<srclen) {
+       while (src < end) {
                bool ok = hex_byte(src, dst);
                if (!ok) {
                        return false;