From 59b90d186cf64cb67aef9a75e430d2ca96caace3 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 4 Nov 2014 17:35:04 +0000 Subject: [PATCH] PRE(sys_openat): when checking whether ARG1 == VKI_AT_FDCWD, be sure 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index c33afb1ddd..d3064f2377 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -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 ); -- 2.47.2