summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Zhiyong <yangzy.fnst@cn.fujitsu.com>2013-11-04 11:26:07 +0800
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-11-07 01:23:54 -0500
commit4e93793da8919a10adc9c96eb82f47c6b134abf2 (patch)
treea569f86f800c1413ed49938da14f3f1fe3ba0a66
parenta1074881b43416018aef2fb8f62ef62f92f0bae7 (diff)
udevadm-settle: add parameters checking
-rw-r--r--src/udev/udevadm-settle.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index c4fc4ee4e5..65508d8c16 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -35,6 +35,7 @@
#include <sys/types.h>
#include "udev.h"
+#include "util.h"
static int adm_settle(struct udev *udev, int argc, char *argv[])
{
@@ -59,11 +60,15 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
for (;;) {
int option;
- int seconds;
option = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL);
- if (option == -1)
+ if (option == -1) {
+ if (optind < argc) {
+ fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
+ exit(EXIT_FAILURE);
+ }
break;
+ }
switch (option) {
case 's':
@@ -72,12 +77,15 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
case 'e':
end = strtoull(optarg, NULL, 0);
break;
- case 't':
- seconds = atoi(optarg);
- if (seconds >= 0)
- timeout = seconds;
- else
- fprintf(stderr, "invalid timeout value\n");
+ case 't': {
+ int r;
+
+ r = safe_atou(optarg, &timeout);
+ if (r < 0) {
+ fprintf(stderr, "Invalid timeout value '%s': %s\n",
+ optarg, strerror(-r));
+ exit(EXIT_FAILURE);
+ };
break;
case 'q':
quiet = 1;