Mark Wielaard c728a3
#include <sys/capability.h>
Mark Wielaard c728a3
#include <stddef.h>
Mark Wielaard c728a3
#include <stdio.h>
Mark Wielaard c728a3
Mark Wielaard c728a3
int
Mark Wielaard c728a3
main (int c, char **argv)
Mark Wielaard c728a3
{
Mark Wielaard c728a3
  struct __user_cap_header_struct hdr;
Mark Wielaard c728a3
  hdr.version = _LINUX_CAPABILITY_VERSION;
Mark Wielaard c728a3
  hdr.pid = 0;
Mark Wielaard c728a3
  (void) capget(&hdr, NULL);
Mark Wielaard c728a3
  switch (hdr.version) {
Mark Wielaard c728a3
    case _LINUX_CAPABILITY_VERSION_1:
Mark Wielaard c728a3
      printf("Version 1\n");
Mark Wielaard c728a3
      break;
Mark Wielaard c728a3
    case _LINUX_CAPABILITY_VERSION_2:
Mark Wielaard c728a3
      printf("Version 2\n");
Mark Wielaard c728a3
      break;
Mark Wielaard c728a3
    default:
Mark Wielaard c728a3
      printf("Unknown version\n");
Mark Wielaard c728a3
      break;
Mark Wielaard c728a3
   }
Mark Wielaard c728a3
  return 0;
Mark Wielaard c728a3
}
Mark Wielaard c728a3
Jakub Jelinek 81c97a
--- valgrind-3.7.0/coregrind/m_syswrap/syswrap-linux.c.jj	2010-04-07 08:14:12.000000000 -0400
Jakub Jelinek 81c97a
+++ valgrind-3.7.0/coregrind/m_syswrap/syswrap-linux.c	2010-04-12 07:24:12.838876000 -0400
Mark Wielaard f4ddfb
@@ -2212,8 +2212,9 @@ PRE(sys_capget)
Jakub Jelinek 7d17c1
                  vki_cap_user_header_t, header, vki_cap_user_data_t, data);
Jakub Jelinek 7d17c1
    PRE_MEM_READ( "capget(header)", ARG1, 
Jakub Jelinek 7d17c1
                   sizeof(struct __vki_user_cap_header_struct) );
Jakub Jelinek 7d17c1
-   PRE_MEM_WRITE( "capget(data)", ARG2, 
Jakub Jelinek 7d17c1
-                  sizeof(struct __vki_user_cap_data_struct) );
Jakub Jelinek 7d17c1
+   if (ARG2 != (Addr)NULL)
Jakub Jelinek 7d17c1
+      PRE_MEM_WRITE( "capget(data)", ARG2, 
Jakub Jelinek 7d17c1
+                      sizeof(struct __vki_user_cap_data_struct) );
Jakub Jelinek 7d17c1
 }
Jakub Jelinek 7d17c1
 POST(sys_capget)
Jakub Jelinek 7d17c1
 {
Mark Wielaard a84d91
--- valgrind/memcheck/tests/x86-linux/scalar.c	(revision 13010)
Mark Wielaard a84d91
+++ valgrind/memcheck/tests/x86-linux/scalar.c	(working copy)
Mark Wielaard a84d91
@@ -813,7 +813,7 @@
Mark Wielaard a84d91
 
Mark Wielaard a84d91
    // __NR_capget 184
Mark Wielaard a84d91
    GO(__NR_capget, "2s 2m");
Mark Wielaard a84d91
-   SY(__NR_capget, x0, x0); FAIL;
Mark Wielaard a84d91
+   SY(__NR_capget, x0, x0+1); FAIL;
Mark Wielaard a84d91
 
Mark Wielaard a84d91
    // __NR_capset 185
Mark Wielaard a84d91
    GO(__NR_capset, "2s 2m");