From: Nick Porter Date: Wed, 9 Mar 2022 15:35:33 +0000 (+0000) Subject: %{bin: } xlat - adjust length of string when removing initial 0x (#4408) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=840e8bed45e3fba1f18f0f24af65ecc08483f216;p=thirdparty%2Ffreeradius-server.git %{bin: } xlat - adjust length of string when removing initial 0x (#4408) --- diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index 7615ef72023..1c3cda16cd9 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -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;