Blob Blame History Raw
#include <sys/capability.h>
#include <stddef.h>
#include <stdio.h>

int
main (int c, char **argv)
{
  struct __user_cap_header_struct hdr;
  hdr.version = _LINUX_CAPABILITY_VERSION;
  hdr.pid = 0;
  (void) capget(&hdr, NULL);
  switch (hdr.version) {
    case _LINUX_CAPABILITY_VERSION_1:
      printf("Version 1\n");
      break;
    case _LINUX_CAPABILITY_VERSION_2:
      printf("Version 2\n");
      break;
    default:
      printf("Unknown version\n");
      break;
   }
  return 0;
}

--- valgrind-3.7.0/coregrind/m_syswrap/syswrap-linux.c.jj	2010-04-07 08:14:12.000000000 -0400
+++ valgrind-3.7.0/coregrind/m_syswrap/syswrap-linux.c	2010-04-12 07:24:12.838876000 -0400
@@ -2212,8 +2212,9 @@ PRE(sys_capget)
                  vki_cap_user_header_t, header, vki_cap_user_data_t, data);
    PRE_MEM_READ( "capget(header)", ARG1, 
                   sizeof(struct __vki_user_cap_header_struct) );
-   PRE_MEM_WRITE( "capget(data)", ARG2, 
-                  sizeof(struct __vki_user_cap_data_struct) );
+   if (ARG2 != (Addr)NULL)
+      PRE_MEM_WRITE( "capget(data)", ARG2, 
+                      sizeof(struct __vki_user_cap_data_struct) );
 }
 POST(sys_capget)
 {
--- valgrind/memcheck/tests/x86-linux/scalar.c	(revision 13010)
+++ valgrind/memcheck/tests/x86-linux/scalar.c	(working copy)
@@ -813,7 +813,7 @@
 
    // __NR_capget 184
    GO(__NR_capget, "2s 2m");
-   SY(__NR_capget, x0, x0); FAIL;
+   SY(__NR_capget, x0, x0+1); FAIL;
 
    // __NR_capset 185
    GO(__NR_capset, "2s 2m");