]> granicus.if.org Git - strace/commitdiff
tests: fix uid tests on big endian architectures
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 2 Mar 2015 01:13:47 +0000 (01:13 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 2 Mar 2015 02:23:55 +0000 (02:23 +0000)
* tests/uid.c (main): Ignore uids returned by getresuid to avoid
16bit vs 32bit issues on big endian architectures.
Change real UID instead of effective UID in setresuid test.
* tests/uid16.c (main): Likewise.
* tests/uid32.c (main): Change real UID instead of effective UID
in setresuid test to match uid.c
* tests/uid.awk: Update setresuid regexp.

Reported-by: Mike Frysinger <vapier@gentoo.org>
tests/uid.awk
tests/uid.c
tests/uid16.c
tests/uid32.c

index b93fa0052e243428389c1cf2378cc82add6f9406..c6e891a3be31c67b0c4a2afd56621b8f17be3af3 100644 (file)
@@ -24,7 +24,7 @@ regexp == "" {
       regexp = "^setreuid" suffix "\\(-1, -1\\)[[:space:]]+= 0$"
     } else if (expected == "setreuid") {
       expected = "setresuid"
-      regexp = "^setresuid" suffix "\\(-1, " uid ", -1\\)[[:space:]]+= 0$"
+      regexp = "^setresuid" suffix "\\(" uid ", -1, -1\\)[[:space:]]+= 0$"
     } else if (expected == "setresuid") {
       expected = "chown"
       regexp = "^chown" suffix "\\(\".\", -1, -1\\)[[:space:]]+= 0$"
index 5687dabde3a0cd5e4289ff42cb2578c82405b9b2..1972044656055e016ed55118c2216a1eb3bbeaee 100644 (file)
@@ -16,15 +16,22 @@ main(void)
  && defined(__NR_setresuid) \
  && defined(__NR_chown) \
  && defined(__NR_getgroups)
-       int r, e, s;
+       int uid;
        int size;
        int *list = 0;
 
-       e = syscall(__NR_getuid);
-       assert(syscall(__NR_setuid, e) == 0);
-       assert(syscall(__NR_getresuid, &r, &e, &s) == 0);
+       uid = syscall(__NR_getuid);
+       assert(syscall(__NR_setuid, uid) == 0);
+       {
+               /*
+                * uids returned by getresuid should be ignored
+                * to avoid 16bit vs 32bit issues.
+                */
+               int r, e, s;
+               assert(syscall(__NR_getresuid, &r, &e, &s) == 0);
+       }
        assert(syscall(__NR_setreuid, -1, -1L) == 0);
-       assert(syscall(__NR_setresuid, -1, e, -1L) == 0);
+       assert(syscall(__NR_setresuid, uid, -1, -1L) == 0);
        assert(syscall(__NR_chown, ".", -1, -1L) == 0);
        assert((size = syscall(__NR_getgroups, 0, list)) >= 0);
        assert(list = calloc(size + 1, sizeof(*list)));
index 820dd90d4f8905b7eb6b0805de9414a4172ecd78..be5cec6d19d658be68b7c411abf969c22841dd29 100644 (file)
@@ -33,15 +33,22 @@ main(void)
  && __NR_chown != __NR_chown32 \
  && __NR_getgroups != __NR_getgroups32 \
  /**/
-       int r, e, s;
+       int uid;
        int size;
        int *list = 0;
 
-       e = syscall(__NR_getuid);
-       assert(syscall(__NR_setuid, e) == 0);
-       assert(syscall(__NR_getresuid, &r, &e, &s) == 0);
+       uid = syscall(__NR_getuid);
+       assert(syscall(__NR_setuid, uid) == 0);
+       {
+               /*
+                * uids returned by getresuid should be ignored
+                * to avoid 16bit vs 32bit issues.
+                */
+               int r, e, s;
+               assert(syscall(__NR_getresuid, &r, &e, &s) == 0);
+       }
        assert(syscall(__NR_setreuid, -1, 0xffff) == 0);
-       assert(syscall(__NR_setresuid, -1, e, 0xffff) == 0);
+       assert(syscall(__NR_setresuid, uid, -1, 0xffff) == 0);
        assert(syscall(__NR_chown, ".", -1, 0xffff) == 0);
        assert((size = syscall(__NR_getgroups, 0, list)) >= 0);
        assert(list = calloc(size + 1, sizeof(*list)));
index 95d04ea9d4fec5fdbe61e0548f0a10f4db04581c..15f120279b714570cb8c250c1edbd8b8585654b9 100644 (file)
@@ -20,11 +20,11 @@ main(void)
        int size;
        int *list = 0;
 
-       e = syscall(__NR_getuid32);
-       assert(syscall(__NR_setuid32, e) == 0);
+       r = syscall(__NR_getuid32);
+       assert(syscall(__NR_setuid32, r) == 0);
        assert(syscall(__NR_getresuid32, &r, &e, &s) == 0);
        assert(syscall(__NR_setreuid32, -1, -1L) == 0);
-       assert(syscall(__NR_setresuid32, -1, e, -1L) == 0);
+       assert(syscall(__NR_setresuid32, r, -1, -1L) == 0);
        assert(syscall(__NR_chown32, ".", -1, -1L) == 0);
        assert((size = syscall(__NR_getgroups32, 0, list)) >= 0);
        assert(list = calloc(size + 1, sizeof(*list)));