uid: print size as signed in setgroups/getgroups

As this is the type used in kernel.

* uid.c (SYS_FUNC(setgroups), SYS_FUNC(getgroups)): Print size parameter
as "%d".
* tests/getgroups.c: Update expected output.
* tests/setgroups.c: Likewise.

Co-authored-by: Elvira Khabirova <lineprinter0@gmail.com>
This commit is contained in:
Eugene Syromyatnikov 2016-11-28 02:51:04 +03:00 committed by Dmitry V. Levin
parent 3304d82108
commit 6be94f1772
3 changed files with 14 additions and 14 deletions

View File

@ -67,7 +67,7 @@ get_groups(const long size, GID_TYPE *const g)
if (i != ngroups)
perror_msg_and_fail("%s(%#lx, %p)", SYSCALL_NAME, size, g);
printf("%s(%u, [", SYSCALL_NAME, (unsigned) size);
printf("%s(%d, [", SYSCALL_NAME, (int) size);
for (i = 0; i < ngroups; ++i) {
if (i)
printf(", ");
@ -95,18 +95,18 @@ main(void)
printf("%s(0, NULL) = %ld\n", SYSCALL_NAME, rc);
rc = syscall(SYSCALL_NR, -1U, 0);
printf("%s(%u, NULL) = %s\n", SYSCALL_NAME, -1U, sprintrc(rc));
printf("%s(%d, NULL) = %s\n", SYSCALL_NAME, -1, sprintrc(rc));
rc = syscall(SYSCALL_NR, -1L, 0);
printf("%s(%u, NULL) = %s\n", SYSCALL_NAME, -1U, sprintrc(rc));
printf("%s(%d, NULL) = %s\n", SYSCALL_NAME, -1, sprintrc(rc));
const unsigned int ngroups_max = sysconf(_SC_NGROUPS_MAX);
rc = syscall(SYSCALL_NR, ngroups_max, 0);
printf("%s(%u, NULL) = %s\n", SYSCALL_NAME, ngroups_max, sprintrc(rc));
printf("%s(%d, NULL) = %s\n", SYSCALL_NAME, ngroups_max, sprintrc(rc));
rc = syscall(SYSCALL_NR, (long) 0xffffffff00000000ULL | ngroups_max, 0);
printf("%s(%u, NULL) = %s\n", SYSCALL_NAME, ngroups_max, sprintrc(rc));
printf("%s(%d, NULL) = %s\n", SYSCALL_NAME, ngroups_max, sprintrc(rc));
/* check how the second argument is decoded */
GID_TYPE *const g1 =
@ -120,7 +120,7 @@ main(void)
if (ngroups) {
rc = syscall(SYSCALL_NR, ngroups, efault);
printf("%s(%u, %p) = %s\n",
printf("%s(%d, %p) = %s\n",
SYSCALL_NAME, (unsigned) ngroups, efault, sprintrc(rc));
}

View File

@ -85,10 +85,10 @@ main(void)
printf("%s(1, NULL) = %s\n", SYSCALL_NAME, sprintrc(rc));
rc = syscall(SYSCALL_NR, -1U, 0);
printf("%s(%u, NULL) = %s\n", SYSCALL_NAME, -1U, sprintrc(rc));
printf("%s(%d, NULL) = %s\n", SYSCALL_NAME, -1, sprintrc(rc));
rc = syscall(SYSCALL_NR, -1L, 0);
printf("%s(%u, NULL) = %s\n", SYSCALL_NAME, -1U, sprintrc(rc));
printf("%s(%d, NULL) = %s\n", SYSCALL_NAME, -1, sprintrc(rc));
/* check how the second argument is decoded */
const GID_TYPE *const g1 = tail_alloc(sizeof(*g1));
@ -158,7 +158,7 @@ main(void)
if ((unsigned long) rc == ngroups_max && (int) ngroups_max > 0) {
rc = syscall(SYSCALL_NR, ngroups_max, g3);
errstr = sprintrc(rc);
printf("%s(%u, [", SYSCALL_NAME, ngroups_max);
printf("%s(%d, [", SYSCALL_NAME, ngroups_max);
printuid(g3[0]);
printf(", ");
printuid(g3[1]);
@ -168,14 +168,14 @@ main(void)
(unsigned long) 0xffffffff00000000ULL | ngroups_max;
rc = syscall(SYSCALL_NR, size, g3);
errstr = sprintrc(rc);
printf("%s(%u, [", SYSCALL_NAME, ngroups_max);
printf("%s(%d, [", SYSCALL_NAME, ngroups_max);
printuid(g3[0]);
printf(", ");
printuid(g3[1]);
printf(", ...]) = %s\n", errstr);
rc = syscall(SYSCALL_NR, ngroups_max + 1, g3);
printf("%s(%u, %p) = %s\n", SYSCALL_NAME,
printf("%s(%d, %p) = %s\n", SYSCALL_NAME,
ngroups_max + 1, g3, sprintrc(rc));
}

6
uid.c
View File

@ -182,9 +182,9 @@ print_groups(struct tcb *tcp, const unsigned int len, const unsigned long addr)
SYS_FUNC(setgroups)
{
const unsigned int len = tcp->u_arg[0];
const int len = tcp->u_arg[0];
tprintf("%u, ", len);
tprintf("%d, ", len);
print_groups(tcp, len, tcp->u_arg[1]);
return RVAL_DECODED;
}
@ -192,7 +192,7 @@ SYS_FUNC(setgroups)
SYS_FUNC(getgroups)
{
if (entering(tcp))
tprintf("%u, ", (unsigned int) tcp->u_arg[0]);
tprintf("%d, ", (int) tcp->u_arg[0]);
else
print_groups(tcp, tcp->u_rval, tcp->u_arg[1]);
return 0;