|
From: <sv...@va...> - 2014-11-04 17:35:14
|
Author: sewardj
Date: Tue Nov 4 17:35:04 2014
New Revision: 14689
Log:
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.
Modified:
trunk/coregrind/m_syswrap/syswrap-linux.c
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c Tue Nov 4 17:35:04 2014
@@ -4389,10 +4389,11 @@
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 );
|