From: Julian Seward Date: Fri, 30 Sep 2005 01:09:50 +0000 (+0000) Subject: In PRE(sys_readlink), fix up handling of /proc//exe and X-Git-Tag: svn/VALGRIND_3_1_0~400 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44e0ab593a78802f52f3c6417ad85db77a87703c;p=thirdparty%2Fvalgrind.git In PRE(sys_readlink), fix up handling of /proc//exe and /proc/self/exe. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4828 --- diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 94de9090c1..ca36d6561c 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -4625,7 +4625,9 @@ POST(sys_poll) PRE(sys_readlink) { - Word saved = SYSNO; + HChar name[25]; + Word saved = SYSNO; + PRINT("sys_readlink ( %p, %p, %llu )", ARG1,ARG2,(ULong)ARG3); PRE_REG_READ3(long, "readlink", const char *, path, char *, buf, int, bufsiz); @@ -4636,20 +4638,15 @@ PRE(sys_readlink) * Handle the case where readlink is looking at /proc/self/exe or * /proc//exe. */ - - SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); - - /* jrs 20050604: where does the magic value 2 come from? It seems - like it should be a kernel error value, but we don't know of any - such. */ - if (SWHAT == SsFailure && RES_unchecked == 2) { - HChar name[25]; - VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)()); - if (VG_(strcmp)((Char *)ARG1, name) == 0 || - VG_(strcmp)((Char *)ARG1, "/proc/self/exe") == 0) { - VG_(sprintf)(name, "/proc/self/fd/%d", VG_(cl_exec_fd)); - SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, (UWord)name, ARG2, ARG3)); - } + VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)()); + if (VG_(strcmp)((Char *)ARG1, name) == 0 + || VG_(strcmp)((Char *)ARG1, "/proc/self/exe") == 0) { + VG_(sprintf)(name, "/proc/self/fd/%d", VG_(cl_exec_fd)); + SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, (UWord)name, + ARG2, ARG3)); + } else { + /* Normal case */ + SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, ARG1, ARG2, ARG3)); } if (SUCCESS && RES > 0)