[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kinit
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2009-07-20 22:40:40
Message-ID: 1248129640.641396.12013.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1000153 by lunakl:

Fix r869616 to really only prevent clearing of memory used by env. variables,
memory used by argv still needs to be cleared, otherwise 'ps ux' and others
may show garbage.



 M  +6 -6      proctitle.cpp  


--- trunk/KDE/kdelibs/kinit/proctitle.cpp #1000152:1000153
@@ -80,6 +80,7 @@
 
 #if PF_ARGV_TYPE == PF_ARGV_WRITEABLE   /* Only this mode uses LastArgv */
 static char *LastArgv = NULL;
+static char *cleanUpTo = NULL;
 #endif
 
 /**
@@ -114,6 +115,7 @@
             LastArgv = argv[i] + strlen(argv[i]);
         }
     }
+    cleanUpTo = LastArgv;
 
     for (i = 0; envp[i] != NULL; i++) {
         /* must not overwrite XDG_SESSION_COOKIE */
@@ -201,17 +203,15 @@
     /* We can overwrite individual argv[] arguments.  Semi-nice. */
     snprintf(Argv[0], maxlen, "%s", statbuf);
     p = &Argv[0][i];
-
-    /* null terminate it, but don't clear the rest of the
-       memory that is usually used for environment variables. Some
+    /* Clear the rest used by arguments, but don't clear the memory
+       that is usually used for environment variables. Some
        tools, like ConsoleKit must have access to the process'es initial
        environment (more exact, the XDG_SESSION_COOKIE variable stored there).
        If this code causes another side effect, we have to specifically
        always append those variables to our environment. */
+    while (p < cleanUpTo)
+        *p++ = '\0';
 
-    if (p < LastArgv)
-        *p = '\0';
-
     Argv[1] = NULL;
 # endif /* PF_ARGV_WRITEABLE */
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic