From c821a1256b3da34a4baf340f051eff853a239836 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 28 Aug 2011 13:16:23 +0200 Subject: [PATCH] ipcmk: validate numeric option arguments Use strtoul_or_err() instead of atoi(). Signed-off-by: Sami Kerola --- sys-utils/Makefile.am | 1 + sys-utils/ipcmk.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys-utils/Makefile.am b/sys-utils/Makefile.am index 1e5dcf40f9..06456acb56 100644 --- a/sys-utils/Makefile.am +++ b/sys-utils/Makefile.am @@ -36,6 +36,7 @@ tunelp_SOURCES = tunelp.c lp.h fstrim_SOURCES = fstrim.c $(top_srcdir)/lib/strutils.c rtcwake_SOURCES = rtcwake.c $(top_srcdir)/lib/strutils.c dmesg_SOURCES = dmesg.c $(top_srcdir)/lib/strutils.c +ipcmk_SOURCES = ipcmk.c $(top_srcdir)/lib/strutils.c if BUILD_MOUNTPOINT bin_PROGRAMS += mountpoint diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c index 50ad79405a..923e2dd477 100644 --- a/sys-utils/ipcmk.c +++ b/sys-utils/ipcmk.c @@ -35,6 +35,7 @@ #include "nls.h" #include "c.h" +#include "strutils.h" key_t createKey(void) { @@ -102,14 +103,14 @@ int main(int argc, char **argv) while((opt = getopt_long(argc, argv, "hM:QS:p:Vh", longopts, NULL)) != -1) { switch(opt) { case 'M': - size = atoi(optarg); + size = strtol_or_err(optarg, _("failed to parse size")); doShm = 1; break; case 'Q': doMsg = 1; break; case 'S': - nsems = atoi(optarg); + nsems = strtol_or_err(optarg, _("failed to parse elements")); doSem = 1; break; case 'p': -- 2.47.3