lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m25y54h9jl.fsf@gmail.com>
Date: Thu, 24 Aug 2023 14:09:02 +0100
From: Donald Hunter <donald.hunter@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net,  netdev@...r.kernel.org,  edumazet@...gle.com,
  pabeni@...hat.com
Subject: Re: [PATCH net-next 1/5] tools: ynl: allow passing binary data

Jakub Kicinski <kuba@...nel.org> writes:

> Recent changes made us assume that input for binary data is in hex.
> When using YNL as a Python library it's possible to pass in raw bytes.
> Bring the ability to do that back.
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
>  tools/net/ynl/lib/ynl.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
> index 6951bcc7efdc..fa4f1c28efc5 100644
> --- a/tools/net/ynl/lib/ynl.py
> +++ b/tools/net/ynl/lib/ynl.py
> @@ -410,7 +410,12 @@ genl_family_name_to_id = None
>          elif attr["type"] == 'string':
>              attr_payload = str(value).encode('ascii') + b'\x00'
>          elif attr["type"] == 'binary':
> -            attr_payload = bytes.fromhex(value)
> +            if isinstance(value, bytes):
> +                attr_payload = value
> +            elif isinstance(value, str):
> +                attr_payload = bytes.fromhex(value)
> +            else:
> +                raise Exception(f'Unknown type for binary attribute, value: {value}')
>          elif attr['type'] in NlAttr.type_formats:
>              format = NlAttr.get_format(attr['type'], attr.byte_order)
>              attr_payload = format.pack(int(value))

Reviewed-by: Donald Hunter <donald.hunter@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ