All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it, Richard Palethorpe <rpalethorpe@suse.com>
Subject: Re: [LTP] [PATCH] syscalls/statvfs01: Correcly zero terminate the strings
Date: Wed, 18 Jan 2023 22:40:42 +0100	[thread overview]
Message-ID: <Y8hnWhiYH/R5ZStF@pevik> (raw)
In-Reply-To: <37ee8021-c13b-c4a9-f27b-84f504800169@suse.cz>

> Hi,

> On 18. 01. 23 14:36, Cyril Hrubis wrote:
> > Fixes random failures caused by the fact that the stack is not
> > guaranteed to be zeroed.

> > Fixes: e305ac4a305f ("statvfs01: Convert to new LTP API")
> > Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> > CC: Petr Vorel <pvorel@suse.cz>
> > CC: Richard Palethorpe <rpalethorpe@suse.com>
> > CC: Avinesh Kumar <akumar@suse.de>
> > ---
> >   testcases/kernel/syscalls/statvfs/statvfs01.c | 3 +++
> >   1 file changed, 3 insertions(+)

> > diff --git a/testcases/kernel/syscalls/statvfs/statvfs01.c b/testcases/kernel/syscalls/statvfs/statvfs01.c
> > index dd14d6a0e..f17dc4cfa 100644
> > --- a/testcases/kernel/syscalls/statvfs/statvfs01.c
> > +++ b/testcases/kernel/syscalls/statvfs/statvfs01.c
> > @@ -38,6 +38,9 @@ static void run(void)
> >   	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 think

PATH_MAX is 4096. statvfs.f_namemax is mostly 255 (only for vfat and exfat is
1530, but that's for multibyte names, the "real" length, when counting
characters is also 255).

> toolong_fname[] size should be bumped to at least PATH_MAX+1.
statvfs01.c:43:22: warning: array subscript 4097 is above array bounds of ‘char[4096]’ [-Warray-bounds]
=> PATH_MAX-1 is the maximum (array size is PATH_MAX).

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-01-18 21:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 13:36 [LTP] [PATCH] syscalls/statvfs01: Correcly zero terminate the strings Cyril Hrubis
2023-01-18 16:40 ` Petr Vorel
2023-01-18 17:01 ` Martin Doucha
2023-01-18 21:40   ` Petr Vorel [this message]
2023-01-19 14:41   ` Cyril Hrubis
2023-01-19 14:56     ` Martin Doucha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y8hnWhiYH/R5ZStF@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    --cc=rpalethorpe@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.