]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
%{bin: } xlat - adjust length of string when removing initial 0x (#4408)
authorNick Porter <nick@portercomputing.co.uk>
Wed, 9 Mar 2022 15:35:33 +0000 (15:35 +0000)
committerGitHub <noreply@github.com>
Wed, 9 Mar 2022 15:35:33 +0000 (10:35 -0500)
src/lib/unlang/xlat_builtin.c

index 7615ef7202356728b646a9e3ebd4a26c37a697df..1c3cda16cd9cdb4921137dacec79cf46f6aa11b8 100644 (file)
@@ -1928,10 +1928,17 @@ static xlat_action_t xlat_func_bin(TALLOC_CTX *ctx, fr_dcursor_t *out,
        p = hex->vb_strvalue;
        end = p + len;
 
+       /*
+        *      Look for 0x at the start of the string
+        */
+       if ((p[0] == '0') && (p[1] == 'x')) {
+               p += 2;
+               len -=2;
+       }
+
        /*
         *      Zero length octets string
         */
-       if ((p[0] == '0') && (p[1] == 'x')) p += 2;
        if (p == end) goto finish;
 
        outlen = len / 2;