]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ipcmk: validate numeric option arguments
authorSami Kerola <kerolasa@iki.fi>
Sun, 28 Aug 2011 11:16:23 +0000 (13:16 +0200)
committerSami Kerola <kerolasa@iki.fi>
Mon, 12 Sep 2011 19:27:07 +0000 (21:27 +0200)
Use strtoul_or_err() instead of atoi().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/Makefile.am
sys-utils/ipcmk.c

index 1e5dcf40f979c0f0030a6cd73b17dd824474a006..06456acb566607177b6f0c94caaf76e0ee87784f 100644 (file)
@@ -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
index 50ad79405a645514f3ffcea4f8ad30b28004d5d7..923e2dd4777e19aa129acaf072869fe355446550 100644 (file)
@@ -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':