From: Nicholas Nethercote Date: Sun, 24 May 2009 22:32:33 +0000 (+0000) Subject: DARWIN sync: sys_open wrapper. X-Git-Tag: svn/VALGRIND_3_5_0~611 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27ff9aaf2985c9389e2e51a36118894c9fb544d6;p=thirdparty%2Fvalgrind.git DARWIN sync: sys_open wrapper. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10131 --- diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 0057339dd0..b716bf00f4 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -3393,9 +3393,6 @@ POST(sys_nanosleep) PRE(sys_open) { - HChar name[30]; - SysRes sres; - if (ARG2 & VKI_O_CREAT) { // 3-arg version PRINT("sys_open ( %#lx(%s), %ld, %ld )",ARG1,(char*)ARG1,ARG2,ARG3); @@ -3413,19 +3410,25 @@ PRE(sys_open) /proc//cmdline, and just give it a copy of the fd for the fake file we cooked up at startup (in m_main). Also, seek the cloned fd back to the start. */ + { + HChar name[30]; + Char* arg1s = (Char*) ARG1; + SysRes sres; - VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)()); - if (ML_(safe_to_deref)( (void*)ARG1, 1 ) - && (VG_(strcmp)((Char *)ARG1, name) == 0 - || VG_(strcmp)((Char *)ARG1, "/proc/self/cmdline") == 0)) { - sres = VG_(dup)( VG_(cl_cmdline_fd) ); - SET_STATUS_from_SysRes( sres ); - if (!sr_isError(sres)) { - OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET ); - if (off < 0) - SET_STATUS_Failure( VKI_EMFILE ); + VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)()); + if (ML_(safe_to_deref)( arg1s, 1 ) && + (VG_STREQ(arg1s, name) || VG_STREQ(arg1s, "/proc/self/cmdline")) + ) + { + sres = VG_(dup)( VG_(cl_cmdline_fd) ); + SET_STATUS_from_SysRes( sres ); + if (!sr_isError(sres)) { + OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET ); + if (off < 0) + SET_STATUS_Failure( VKI_EMFILE ); + } + return; } - return; } /* Otherwise handle normally */