parser: fix struct size for get_task_comm() 05/172205/3 accepted/tizen/unified/20180314.062051 submit/tizen/20180309.021822 submit/tizen/20180313.082249
authorAlexander Aksenov <a.aksenov@samsung.com>
Mon, 12 Mar 2018 13:57:09 +0000 (16:57 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Mon, 12 Mar 2018 16:49:58 +0000 (19:49 +0300)
Now the field where task comm is collected is declared of size
TASK_COMM_LEN

Change-Id: I6bda4ecbdb85e16e752211b59038238d3b1a55d1
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
modules/parser/usm_msg.c

index 71009ac179a5a386118fca5c39432e9ac94716f3..673fad70789ad4ce6333fbb07680879ac643ff77 100644 (file)
@@ -138,7 +138,7 @@ cp2buf:
  */
 struct proc_info_top {
        u32 pid;
-       char comm[0];
+       char comm[TASK_COMM_LEN];
 } __packed;
 
 struct proc_info_bottom {
@@ -260,15 +260,19 @@ out:
 static int pack_proc_info_top(void *data, size_t size,
                              struct task_struct *task)
 {
-       struct proc_info_top *pit = (struct proc_info_top *)data;
+       struct proc_info_top *pit;
 
-       if (size < sizeof(*pit) + sizeof(task->comm))
+       if (size < sizeof(*pit))
                return -ENOMEM;
 
+       pit = (struct proc_info_top *)data;
+
        pit->pid = task->tgid;
        get_task_comm(pit->comm, task);
 
-       return sizeof(*pit) + strlen(pit->comm) + 1;
+       /* Only meaningful part of pit->comm is packed, so only meaningful size
+        * is returned */
+       return sizeof(pit->pid) + strlen(pit->comm) + 1;
 }
 
 static int pack_proc_info_bottom(void *data, size_t size,
@@ -479,7 +483,8 @@ void usm_msg_unmap(unsigned long start, unsigned long end)
  */
 struct proc_comm {
        u32 pid;
-       char comm[0];
+       /* Only meaningful part is packed */
+       char comm[TASK_COMM_LEN];
 } __packed;
 
 void usm_msg_comm(struct task_struct *task)