From 6be94f17727d4c546f6a10bbf64296664229fde3 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Mon, 28 Nov 2016 02:51:04 +0300 Subject: [PATCH] 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 --- tests/getgroups.c | 12 ++++++------ tests/setgroups.c | 10 +++++----- uid.c | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/getgroups.c b/tests/getgroups.c index 4abcdef7..2617303f 100644 --- a/tests/getgroups.c +++ b/tests/getgroups.c @@ -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)); } diff --git a/tests/setgroups.c b/tests/setgroups.c index 18295c6b..1ec8333f 100644 --- a/tests/setgroups.c +++ b/tests/setgroups.c @@ -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)); } diff --git a/uid.c b/uid.c index a9657169..815a4144 100644 --- a/uid.c +++ b/uid.c @@ -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;