[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220830163441.q272do6lred23iqw@moria.home.lan>
Date: Tue, 30 Aug 2022 12:34:41 -0400
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: [PATCH 1/2] lib/test_printf.c: Add ip6 tests
On Tue, Aug 30, 2022 at 09:32:19AM +0200, Rasmus Villemoes wrote:
> On 30/08/2022 03.47, Sergey Senozhatsky wrote:
> > On (22/08/29 20:31), Kent Overstreet wrote:
> >> diff --git a/lib/test_printf.c b/lib/test_printf.c
> >> index 4bd15a593f..6a56dbf076 100644
> >> --- a/lib/test_printf.c
> >> +++ b/lib/test_printf.c
> >> @@ -18,6 +18,7 @@
> >> #include <linux/dcache.h>
> >> #include <linux/socket.h>
> >> #include <linux/in.h>
> >> +#include <linux/in6.h>
> >>
> >> #include <linux/gfp.h>
> >> #include <linux/mm.h>
> >> @@ -61,6 +62,9 @@ do_test(int bufsize, const char *expect, int elen,
> >> pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d\n",
> >> bufsize, fmt, ret, elen);
> >> return 1;
> >> + pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d (%s != %s)\n",
> >> + bufsize, fmt, ret, elen, test_buffer, expect);
> >> + return 1;
> >> }
> >
> > I assume you intended to replace first pr_warn() with the second one?
>
> Probably, but that's not ok. The test framework does not trust
> vsnprintf(), especially not when it does not behave as expected. So I
> very much carefully do not treat the buffer as a nul-terminated string
> until I have verified that it does have a nul character (that's tested a
> few lines below), and then when I compare the buffer contents can I pass
> it as a %s argument. Also note how that test takes the 'we may be
> testing a truncated write' into consideration, by printing the expect
> string via %.*s.
>
> tl;dr, please just remove that hunk.
Debugging code I meant to remove, whoops.
Powered by blists - more mailing lists