summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcutils.c
diff options
context:
space:
mode:
authorKarel Zak2014-12-19 13:42:41 +0100
committerKarel Zak2014-12-19 13:42:41 +0100
commit929c257548049f34d357355fc72a6f1540f751cf (patch)
tree954a8a9338ce5b59fdf16923d2ecbc4dc8e49fff /sys-utils/ipcutils.c
parenttests: don't check the current ipcs limits (diff)
downloadkernel-qcow2-util-linux-929c257548049f34d357355fc72a6f1540f751cf.tar.gz
kernel-qcow2-util-linux-929c257548049f34d357355fc72a6f1540f751cf.tar.xz
kernel-qcow2-util-linux-929c257548049f34d357355fc72a6f1540f751cf.zip
ipcs: fix shmctl() usage
The function shmctl() has to be called with 'struct shmid_ds', and if you need 'struct shminfo' then the right way is to cast: bad way: struct shm_info info; shmctl(0, SHM_INFO, &info); right way: struct shmid_ds buf; struct shm_info *info; shmctl(0, SHM_INFO, &buf); info = (struct shm_info *) &buf); The patch also fixes bug in ipc_shm_get_limits() where is missing lim->shmmax in code based on shmctl(). Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/ipcutils.c')
-rw-r--r--sys-utils/ipcutils.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys-utils/ipcutils.c b/sys-utils/ipcutils.c
index 3d5249c93..d1858a06a 100644
--- a/sys-utils/ipcutils.c
+++ b/sys-utils/ipcutils.c
@@ -1,4 +1,3 @@
-
#include <inttypes.h>
#include "c.h"
@@ -82,12 +81,15 @@ int ipc_shm_get_limits(struct ipc_limits *lim)
lim->shmmni = path_read_u64(_PATH_PROC_IPC_SHMMNI);
} else {
- struct shminfo shminfo;
+ struct shminfo *shminfo;
+ struct shmid_ds shmbuf;
- if (shmctl(0, IPC_INFO, (struct shmid_ds *) &shminfo) < 0)
+ if (shmctl(0, IPC_INFO, &shmbuf) < 0)
return 1;
- lim->shmmni = shminfo.shmmni;
- lim->shmall = shminfo.shmall;
+ shminfo = (struct shminfo *) &shmbuf;
+ lim->shmmni = shminfo->shmmni;
+ lim->shmall = shminfo->shmall;
+ lim->shmmax = shminfo->shmmax;
}
return 0;