diff options
author | Sami Kerola | 2011-07-26 00:04:34 +0200 |
---|---|---|
committer | Sami Kerola | 2011-07-26 18:15:14 +0200 |
commit | 4ac41d6114d57a6b404185f055f796ccbf8e1967 (patch) | |
tree | 8264ca6de474b087a0350a0a1e1083ed047e91c1 /hwclock/hwclock.c | |
parent | hwclock: move long options away from global scope (diff) | |
download | kernel-qcow2-util-linux-4ac41d6114d57a6b404185f055f796ccbf8e1967.tar.gz kernel-qcow2-util-linux-4ac41d6114d57a6b404185f055f796ccbf8e1967.tar.xz kernel-qcow2-util-linux-4ac41d6114d57a6b404185f055f796ccbf8e1967.zip |
hwclock: validate numeric option arguments
Instead atoi() use strtoul_or_err().
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'hwclock/hwclock.c')
-rw-r--r-- | hwclock/hwclock.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/hwclock/hwclock.c b/hwclock/hwclock.c index 2c35e857a..b8623d21e 100644 --- a/hwclock/hwclock.c +++ b/hwclock/hwclock.c @@ -74,6 +74,7 @@ #include "clock.h" #include "nls.h" #include "pathnames.h" +#include "strutils.h" #ifdef HAVE_LIBAUDIT #include <libaudit.h> @@ -143,7 +144,7 @@ bool debug; bool badyear; /* User-specified epoch, used when rtc fails to return epoch. */ -int epoch_option = -1; +unsigned long epoch_option = -1; /* * Almost all Award BIOS's made between 04/26/94 and 05/31/95 have a nasty @@ -1307,7 +1308,7 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile, static void manipulate_epoch(const bool getepoch __attribute__ ((__unused__)), const bool setepoch __attribute__ ((__unused__)), - const int epoch_opt __attribute__ ((__unused__)), + const unsigned long epoch_opt __attribute__ ((__unused__)), const bool testing __attribute__ ((__unused__))) { warnx(_("The kernel keeps an epoch value for the Hardware Clock " @@ -1319,7 +1320,7 @@ manipulate_epoch(const bool getepoch __attribute__ ((__unused__)), static void manipulate_epoch(const bool getepoch, const bool setepoch, - const int epoch_opt, + const unsigned long epoch_opt, const bool testing) { if (getepoch) { @@ -1600,7 +1601,8 @@ int main(int argc, char **argv) date_opt = optarg; /* --date */ break; case OPT_EPOCH: - epoch_option = atoi(optarg); /* --epoch */ + epoch_option = /* --epoch */ + strtoul_or_err(optarg, _("failed to parse epoch")); break; case OPT_ADJFILE: adj_file_name = optarg; /* --adjfile */ |