[LTP] [PATCH v3 3/3] syscalls/setgroups03: Convert to new API
Cyril Hrubis
chrubis@suse.cz
Mon Aug 14 16:49:07 CEST 2023
Hi!
> + * 05/2002 Ported by André Merlier
^
I suppose that this is the line that confuses your email client or mail
server so that we end up with invalid encoding.
I've managed to hand edit the patch so that it applies and I've replaced
the invalid sequence with ascii 'e' character.
I've also fixed the safe buffers part. The glist3 is supposed to be set
to bad addres, it does not make sense to allocate it as a safe buffer at
all and then replace the value in setup. The glist1 has to be allocated
with a proper size instead of allocated with SAFE_MALLOC(). And the
glist2 can be just single entry just like in the second test, but should
be initialized properly, the bonus point is that we get rid of the
GID16_CHECK() that way as well.
Pushed with folling diff, thanks.
diff --git a/testcases/kernel/syscalls/setgroups/setgroups03.c b/testcases/kernel/syscalls/setgroups/setgroups03.c
index d0331b216..fbf8de0bb 100644
--- a/testcases/kernel/syscalls/setgroups/setgroups03.c
+++ b/testcases/kernel/syscalls/setgroups/setgroups03.c
@@ -4,7 +4,7 @@
* Copyright (c) International Business Machines Corp., 2001
* Copyright (c) Linux Test Project, 2003-2023
* 07/2001 Ported by Wayne Boyer
* 05/2002 Ported by Andre Merlier
*/
/*\
@@ -36,7 +36,7 @@ static struct tcase {
int exp_errno;
} tcases[] = {
{NGROUPS + 1, &glist1, EINVAL},
- {NGROUPS, &glist2, EPERM},
+ {1, &glist2, EPERM},
{NGROUPS, &glist3, EFAULT},
};
@@ -56,32 +56,20 @@ static void verify_setgroups(unsigned int i)
static void setup(void)
{
- glist1 = SAFE_MALLOC((NGROUPS + 1) * sizeof(GID_T));
-
user_info = SAFE_GETPWNAM(TESTUSER);
- GID16_CHECK(user_info->pw_gid, getpwnam);
- glist2 = (GID_T *)&(user_info->pw_gid);
-
+ glist2[0] = 42;
glist3 = tst_get_bad_addr(NULL);
}
-static void cleanup(void)
-{
- if (glist1)
- free(glist1);
-}
-
static struct tst_test test = {
.test = verify_setgroups,
.tcnt = ARRAY_SIZE(tcases),
.bufs = (struct tst_buffers []) {
- {&glist1, .size = sizeof(GID_T)},
+ {&glist1, .size = sizeof(GID_T) * (NGROUPS + 1)},
{&glist2, .size = sizeof(GID_T)},
- {&glist3, .size = sizeof(GID_T)},
{&user_info, .size = sizeof(struct passwd)},
{},
},
.setup = setup,
- .cleanup = cleanup,
.needs_root = 1,
};
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list