|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 20/24] If FILENAME_MAX is defined, use it instead of arbitrary value (fix format-truncation errors with GCC >= 7)
On Tue, Dec 29, 2020 at 03:51:55PM +0100, Roger Pau Monné wrote:
> I think it's dangerous to do this, specially on the stack, GNU libc
> manual states:
>
> Usage Note: Don?t use FILENAME_MAX as the size of an array in which to
> store a file name! You can?t possibly make an array that big! Use
> dynamic allocation (see Memory Allocation) instead.
>
> I think it would be better to replace the snprintf calls with asprintf
> and free the buffer afterwards.
I went this route, thanks
> Setting file_name to 284 should be
> fine however, as d_name is 256 max and the paths above are 26 maximum
> I think (27 with the nul character).
On NetBSD d_name is 512 ... I guess this is why gcc complains.
--
Manuel Bouyer <bouyer@xxxxxxxxxxxxxxx>
NetBSD: 26 ans d'experience feront toujours la difference
--
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |