[LTP] [PATCH] syscalls/statvfs01: Correcly zero terminate the strings
Cyril Hrubis
chrubis@suse.cz
Thu Jan 19 15:41:13 CET 2023
Hi!
> > memset(valid_fname, 'a', valid_len);
> > memset(toolong_fname, 'b', valid_len + 1);
> >
> > + valid_fname[valid_len] = 0;
> > + toolong_fname[valid_len+1] = 0;
>
> Is there a possibility that valid_len could be equal to PATH_MAX-1?
I do not think so, POSIX explicitly says that PATH_MAX should include
space for terminating null character.
Btw there is NAME_MAX constant that is defined to 256 which is the
usuall maximal lenght + 1.
> I think toolong_fname[] size should be bumped to at least PATH_MAX+1.
Well we can do that (in a separate patch) to be extra sure, but even
then the PATH_MAX seems to be at least order of magnitude larger than
NAME_MAX.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list