summaryrefslogtreecommitdiff
path: root/usr.bin/ipcrm/ipcrm.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/ipcrm/ipcrm.c')
-rw-r--r--usr.bin/ipcrm/ipcrm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/ipcrm/ipcrm.c b/usr.bin/ipcrm/ipcrm.c
index aa11580cbf4..4f70c629848 100644
--- a/usr.bin/ipcrm/ipcrm.c
+++ b/usr.bin/ipcrm/ipcrm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipcrm.c,v 1.10 2005/12/19 19:13:50 millert Exp $*/
+/* $OpenBSD: ipcrm.c,v 1.11 2015/04/18 18:28:37 deraadt Exp $*/
/*
* Copyright (c) 1994 Adam Glass
@@ -39,6 +39,7 @@
#include <sys/shm.h>
#include <stdio.h>
#include <unistd.h>
+#include <limits.h>
#include <stdlib.h>
#include <ctype.h>
#include <err.h>
@@ -112,6 +113,7 @@ int
main(int argc, char *argv[])
{
int c, result, errflg, target_id;
+ const char *errstr;
key_t target_key;
errflg = 0;
@@ -122,7 +124,9 @@ main(int argc, char *argv[])
case 'q':
case 'm':
case 's':
- target_id = atoi(optarg);
+ target_id = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-%c %s: %s\n", c, optarg, &errstr);
if (c == 'q')
result = msgrm(0, target_id);
else if (c == 'm')