]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Linux system call wrappers: truncate ioctl request number to 32 bits
authorBart Van Assche <bvanassche@acm.org>
Tue, 5 Aug 2014 11:35:48 +0000 (11:35 +0000)
committerBart Van Assche <bvanassche@acm.org>
Tue, 5 Aug 2014 11:35:48 +0000 (11:35 +0000)
As explained in https://bugs.kde.org/show_bug.cgi?id=331829, when passing
an ioctl request number as an int to a function the request number will
be sign-extended to 64 bits on 64-bit systems. Avoid that this causes
Valgrind to fail to recognize an ioctl by truncating the request number
to 32 bits.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14232

coregrind/m_syswrap/syswrap-linux.c

index f83b59fb8cd470c9190dbe3287508662b1eb82a2..20b6d0e1cea7cacb07aafbddd2d2efb704d7cfc9 100644 (file)
@@ -5373,6 +5373,8 @@ PRE(sys_ioctl)
 {
    *flags |= SfMayBlock;
 
+   ARG2 = (UInt)ARG2;
+
    // We first handle the ones that don't use ARG3 (even as a
    // scalar/non-pointer argument).
    switch (ARG2 /* request */) {
@@ -7103,6 +7105,8 @@ POST(sys_ioctl)
 {
    vg_assert(SUCCESS);
 
+   ARG2 = (UInt)ARG2;
+
    /* --- BEGIN special IOCTL handlers for specific Android hardware --- */
 
 #  if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \