]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
PRE(sys_openat): when checking whether ARG1 == VKI_AT_FDCWD, be sure
authorJulian Seward <jseward@acm.org>
Tue, 4 Nov 2014 17:35:04 +0000 (17:35 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 4 Nov 2014 17:35:04 +0000 (17:35 +0000)
only to check the lowest 32 bits, since that arg is a file descriptor
-- hence "int" -- and checking all 64 bits fails unexpectedly if ARG1
and VKI_AT_FDCWD are not both zero- or sign- extended.

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

coregrind/m_syswrap/syswrap-linux.c

index c33afb1ddd00e35a13bd9a514b6fdd467064dfb3..d3064f23773f4369edf4642152e95ab07429c2b0 100644 (file)
@@ -4389,10 +4389,11 @@ PRE(sys_openat)
    PRE_MEM_RASCIIZ( "openat(filename)", ARG2 );
 
    /* For absolute filenames, dfd is ignored.  If dfd is AT_FDCWD,
-      filename is relative to cwd.  */
+      filename is relative to cwd.  When comparing dfd against AT_FDCWD,
+      be sure only to compare the bottom 32 bits. */
    if (ML_(safe_to_deref)( (void*)ARG2, 1 )
        && *(Char *)ARG2 != '/'
-       && ARG1 != VKI_AT_FDCWD
+       && ((Int)ARG1) != ((Int)VKI_AT_FDCWD)
        && !ML_(fd_allowed)(ARG1, "openat", tid, False))
       SET_STATUS_Failure( VKI_EBADF );