diff options
author | 2015-08-01 10:25:55 +0000 | |
---|---|---|
committer | 2015-08-01 10:25:55 +0000 | |
commit | 0f8c2526cd0b74e7c575c9254be2e155c14ddf6b (patch) | |
tree | d864c49e9019e59946f3c1a4fb591dc7ae1a4894 /pw/pw_conf.c | |
parent | b3591c99a329ccaa6eb1c750cd56e5302278b288 (diff) | |
download | pw-darwin-0f8c2526cd0b74e7c575c9254be2e155c14ddf6b.tar.gz pw-darwin-0f8c2526cd0b74e7c575c9254be2e155c14ddf6b.tar.zst pw-darwin-0f8c2526cd0b74e7c575c9254be2e155c14ddf6b.zip |
Validate expiration days and password days from commmand line and pw.conf
Diffstat (limited to 'pw/pw_conf.c')
-rw-r--r-- | pw/pw_conf.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/pw/pw_conf.c b/pw/pw_conf.c index c6a86b7..c1b5b33 100644 --- a/pw/pw_conf.c +++ b/pw/pw_conf.c @@ -355,12 +355,20 @@ read_userconfig(char const * file) } break; case _UC_EXPIRE: - if ((q = unquote(q)) != NULL && isdigit(*q)) - config.expire_days = atoi(q); + if ((q = unquote(q)) != NULL) { + errstr = NULL; + config.expire_days = strtonum(q, 0, INT_MAX, &errstr); + if (errstr) + warnx("Invalid expire days: '%s', ignoring", q); + } break; case _UC_PASSWORD: - if ((q = unquote(q)) != NULL && isdigit(*q)) - config.password_days = atoi(q); + if ((q = unquote(q)) != NULL) { + errstr = NULL; + config.password_days = strtonum(q, 0, INT_MAX, &errstr); + if (errstr) + warnx("Invalid password days: '%s', ignoring", q); + } break; case _UC_FIELDS: case _UC_NONE: |