commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 78/87: Fix proc_getprocinfo calls


From: Samuel Thibault
Subject: [hurd] 78/87: Fix proc_getprocinfo calls
Date: Sun, 09 Nov 2014 11:05:06 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit 673603dae49fd06de782780a38e2914ed8cd8777
Author: Samuel Thibault <address@hidden>
Date:   Sun Nov 2 12:29:27 2014 +0100

    Fix proc_getprocinfo calls
    
    The procinfoCnt argument is the number of elements of the procinfo_t array,
    not its size in bytes.
    
    * exec/elfcore.c (dump_core): Fix procinfoCnt given to proc_getprocinfo.
    * libps/procstat.c (merge_procinfo): Likewise.
    * utils/login.c (check_owned): Likewise.
---
 exec/elfcore.c   | 2 +-
 libps/procstat.c | 4 ++--
 utils/login.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/exec/elfcore.c b/exec/elfcore.c
index 1f9238b..033604c 100644
--- a/exec/elfcore.c
+++ b/exec/elfcore.c
@@ -334,7 +334,7 @@ dump_core (task_t task, file_t file, off_t corelimit,
     mach_msg_type_number_t num_waits = 0;
     char pibuf[offsetof (struct procinfo, threadinfos[2])];
     struct procinfo *pi = (void *) &pibuf;
-    mach_msg_type_number_t pi_size = sizeof pibuf;
+    mach_msg_type_number_t pi_size = sizeof pibuf / sizeof(*(procinfo_t*)0);
 
     memset (&pstatus.data, 0, sizeof pstatus.data);
     memset (&psinfo.data, 0, sizeof psinfo.data);
diff --git a/libps/procstat.c b/libps/procstat.c
index 0d4a565..b00c9e4 100644
--- a/libps/procstat.c
+++ b/libps/procstat.c
@@ -192,7 +192,7 @@ merge_procinfo (struct proc_stat *ps, ps_flags_t need, 
ps_flags_t have)
        return ENOMEM;
     }
   new_pi = ps->proc_info;
-  new_pi_size = ps->proc_info_size;
+  new_pi_size = ps->proc_info_size / sizeof(*(procinfo_t)0);
 
   if (really_need & PSTAT_THREAD_WAITS)
     /* We're going to get thread waits info, so make some storage for it too.*/
@@ -240,7 +240,7 @@ merge_procinfo (struct proc_stat *ps, ps_flags_t need, 
ps_flags_t have)
       else
        free (ps->proc_info);
       ps->proc_info = new_pi;
-      ps->proc_info_size = new_pi_size;
+      ps->proc_info_size = new_pi_size * sizeof(*(procinfo_t)0);
       ps->proc_info_vm_alloced = 1;
     }
 
diff --git a/utils/login.c b/utils/login.c
index cad3b1e..40bc3f4 100644
--- a/utils/login.c
+++ b/utils/login.c
@@ -263,7 +263,7 @@ check_owned (process_t proc_server, pid_t pid, int *owned)
   char *waits = 0;
   mach_msg_type_number_t num_waits = 0;
   struct procinfo _pi, *pi = &_pi;
-  mach_msg_type_number_t pi_size = sizeof pi;
+  mach_msg_type_number_t pi_size = sizeof _pi / sizeof(*(procinfo_t)0);
   error_t err =
     proc_getprocinfo (proc_server, pid, &flags, (procinfo_t *)&pi, &pi_size,
                      &waits, &num_waits);

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]