]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When '-d' (one or more) is specified, disallow the client from closing
authorJulian Seward <jseward@acm.org>
Sat, 13 Jan 2007 22:27:51 +0000 (22:27 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 13 Jan 2007 22:27:51 +0000 (22:27 +0000)
fd 2 (stderr) since that's what m_debuglog writes to, and the
resulting disappearance of the debug log can be confusing.

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

coregrind/m_syswrap/syswrap-aix5.c
coregrind/m_syswrap/syswrap-generic.c

index e0a518b1fc29d602263e5fa00206a9532bf1a232..7bc970e50c985444b527713f3919c35da0425775 100644 (file)
@@ -764,6 +764,10 @@ PRE(sys_close)
 {
    PRINT("close ( %ld )", ARG1);
    PRE_REG_READ1(void, "close", UInt, fd);
+   /* If doing -d style logging (which is to fd=2), don't allow that
+      to be closed. */
+   if (ARG1 == 2/*stderr*/ && VG_(debugLog_getLevel)() > 0)
+      SET_STATUS_Failure( VKI_EBADF );
 }
 
 PRE(sys_connext)
index 02daf2d83dad79018b99b68dc9947596fe98fc40..c3a10a08e6e28baebebabe085d45815cadfdbe50 100644 (file)
@@ -2668,7 +2668,10 @@ PRE(sys_close)
    PRE_REG_READ1(long, "close", unsigned int, fd);
 
    /* Detect and negate attempts by the client to close Valgrind's log fd */
-   if (!ML_(fd_allowed)(ARG1, "close", tid, False))
+   if ( (!ML_(fd_allowed)(ARG1, "close", tid, False))
+        /* If doing -d style logging (which is to fd=2), don't
+           allow that to be closed either. */
+        || (ARG1 == 2/*stderr*/ && VG_(debugLog_getLevel)() > 0) )
       SET_STATUS_Failure( VKI_EBADF );
 }