On Mon, May 11, 2020 at 8:05 AM Ondrej Mosnacek <omosnace@xxxxxxxxxx> wrote: > > On Fri, May 8, 2020 at 9:37 PM Stephen Smalley > <stephen.smalley.work@xxxxxxxxx> wrote: > > As per the man page, quotactl(2) expects to be passed a pointer to > > a 4-byte buffer for Q_GETFMT. The kernel copies a single u32 value. > > On Ubuntu, this was detected as a stack smash when running the test. > > Fix the test program. > > > > Signed-off-by: Stephen Smalley <stephen.smalley.work@xxxxxxxxx> > > --- > > tests/filesystem/quotas_test.c | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/tests/filesystem/quotas_test.c b/tests/filesystem/quotas_test.c > > index 8359811..1424362 100644 > > --- a/tests/filesystem/quotas_test.c > > +++ b/tests/filesystem/quotas_test.c > > @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) > > int opt, result, qcmd, save_err, test_id = geteuid(); > > char *context, *src = NULL, *tgt = NULL; > > bool verbose = false; > > - char fmt_buf[2]; > > + unsigned int fmtval; > > I wish we could use something like uint32_t here to make the size > explicit, but that's a C99 thing... OTOH the binder test code already > happily uses C99 stuff, so I'm not sure how to best handle this... > (Add -std=c99 to CFLAGS? Just use <stdint.h> and assume the compiler > has it? Avoid using C99 library features?) I'll add stdint.h and use uint32_t. We already use the fixed-size types in a couple other tests and in the userspace.