[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240219093139.5d86c69c@hermes.local>
Date: Mon, 19 Feb 2024 09:31:39 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Maks Mishin <maks.mishinfz@...il.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH] ipmaddr: Add check for result of sscanf
On Sun, 18 Feb 2024 23:42:03 +0300
Maks Mishin <maks.mishinfz@...il.com> wrote:
> Added comparison of result sscanf with 2 to avoid
> potential troubles with args of sscanf.
> Found by RASU JSC.
>
> Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
> ---
> ip/ipmaddr.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c
> index 2418b303..00e91004 100644
> --- a/ip/ipmaddr.c
> +++ b/ip/ipmaddr.c
> @@ -148,7 +148,9 @@ static void read_igmp(struct ma_info **result_p)
> if (buf[0] != '\t') {
> size_t len;
>
> - sscanf(buf, "%d%s", &m.index, m.name);
> + if (sscanf(buf, "%d%s", &m.index, m.name) != 2)
> + return;
> +
You didn't look at surrounding code.
That will leak the file descriptor.
Please review you patches more carefully.
This is reading from kernel /proc/net/igmp. And the ABI for that is
stable so not a serious concern. It would be good if this was available
over better API like netlink, but few users get into the weed of multicast.
Powered by blists - more mailing lists