]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: remove trailing space in psargs
authorKris Van Hees <kris.van.hees@oracle.com>
Wed, 14 Oct 2015 09:33:08 +0000 (05:33 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Fri, 13 Nov 2015 08:18:11 +0000 (03:18 -0500)
Due to an implementation error, the psargs string contained a trailing
space that was not meant to be there.  This has been corrected.

Orabug: 21974606
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Acked-by: Nick Alcock <nick.alcock@oracle.com>
include/linux/dtrace_psinfo.h
kernel/dtrace/dtrace_os.c

index 050d91f1d9b407a263d395512e6c985b93d19313..0151fd8679ee8580d022367d21def79e77e98ba7 100644 (file)
@@ -17,6 +17,7 @@ typedef struct dtrace_psinfo {
                struct dtrace_psinfo *next;
        };
        char **argv;
+       unsigned long envc;
        char **envp;
        char psargs[PR_PSARGS_SZ];
 } dtrace_psinfo_t;
index c8076468d7094d9af63cd4bf52a841a4f1171935..577933abf824fa8309b529d91590500e5e3b3236 100644 (file)
@@ -113,25 +113,30 @@ void dtrace_psinfo_alloc(struct task_struct *tsk)
        mm = get_task_mm(tsk);
        if (mm) {
                size_t  len = mm->arg_end - mm->arg_start;
-               int     i, envc = 0;
+               int     i = 0;
                char    *p;
 
                /*
                 * Construct the psargs string.
                 */
-               if (len >= PR_PSARGS_SZ)
-                       len = PR_PSARGS_SZ - 1;
+               if (len > 0) {
+                       if (len >= PR_PSARGS_SZ)
+                               len = PR_PSARGS_SZ - 1;
+
+                       i = access_process_vm(tsk, mm->arg_start,
+                                             psinfo->psargs, len, 0);
+                       if (i < len)
+                               len = i;
+
+                       for (i = 0, --len; i < len; i++) {
+                               if (psinfo->psargs[i] == '\0')
+                                       psinfo->psargs[i] = ' ';
+                       }
+               }
 
-               i = access_process_vm(tsk, mm->arg_start, psinfo->psargs,
-                                       len, 0);
                while (i < PR_PSARGS_SZ)
                        psinfo->psargs[i++] = 0;
 
-               for (i = 0; i < len; i++) {
-                       if (psinfo->psargs[i] == '\0')
-                               psinfo->psargs[i] = ' ';
-               }
-
                /*
                 * Determine the number of arguments.
                 */
@@ -169,8 +174,9 @@ void dtrace_psinfo_alloc(struct task_struct *tsk)
                /*
                 * Determine the number of environment variables.
                 */
+               psinfo->envc = 0;
                for (p = (char *)mm->env_start; p < (char *)mm->env_end;
-                    envc++) {
+                    psinfo->envc++) {
                        size_t  l = strnlen_user(p, MAX_ARG_STRLEN);
 
                        if (!l)
@@ -182,7 +188,7 @@ void dtrace_psinfo_alloc(struct task_struct *tsk)
                /*
                 * Limit the number of stored environment pointers.
                 */
-               if ((len = envc) >= PR_ENVP_SZ)
+               if ((len = psinfo->envc) >= PR_ENVP_SZ)
                        len = PR_ENVP_SZ - 1;
 
                psinfo->envp = kmalloc((len + 1) * sizeof(char *),
@@ -218,6 +224,7 @@ void dtrace_psinfo_alloc(struct task_struct *tsk)
                psinfo->argc = 0;
                psinfo->argv = kmalloc(sizeof(char *), GFP_KERNEL);
                psinfo->argv[0] = NULL;
+               psinfo->envc = 0;
                psinfo->envp = kmalloc(sizeof(char *), GFP_KERNEL);
                psinfo->envp[0] = NULL;
        }