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]
Date:	Mon, 30 Mar 2015 10:35:10 +0200
From:	Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
To:	Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:	Bryan Wu <cooloney@...il.com>, Richard Purdie <rpurdie@...ys.net>,
	"linux-leds@...r.kernel.org" <linux-leds@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] led/led-class: Handle LEDs with the same name

Hello Geert:

Thanks for your comments!

On Mon, Mar 30, 2015 at 9:59 AM, Geert Uytterhoeven
<geert@...ux-m68k.org> wrote:
>
> What's the maximum length of init_name?

It is "driver defined", this is why the initial patch used kasprintf,
but the Maintainer preferred to avoid the memory handling.

> strncpy() is _not_ guaranteed to zero-terminate the destination buffer.

Good catch. I will fix this.

>
> There are two ways to fix this:
>   1. Use strlcpy() instead of strncpy(),
>   2. Explicitly set name[len-1] to 0 after the call to strncpy().
>
> As we don't need the "security" feature of strncpy() that fills the remaining
> part of the buffer with zeroes, I think using strlcpy() is the best solution.
>
>> +       while (class_find_device(leds_class, NULL, name, match_name))
>> +               snprintf(name, len, "%s_%d", init_name, ++i);
>
> This will become an infinite loop once the resulting string no longer fits in
> the target buffer. Hence the loop should be terminated, and an error code
> should be returned, once snprintf() returns a value >= len.
>

Will send a patch right away. Thanks

>> +
>> +       return i;
>> +}
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds



-- 
Ricardo Ribalda
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ