watch: use strtod_or_err() to validate user input
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
208a043256
commit
5862f47b96
@ -61,7 +61,8 @@ dist_man_MANS += \
|
||||
slabtop_SOURCES = slabtop.c $(top_srcdir)/lib/strutils.c
|
||||
slabtop_LDADD = @NCURSES_LIBS@
|
||||
top_LDADD = @NCURSES_LIBS@
|
||||
watch_LDADD = @WATCH_NCURSES_LIBS@
|
||||
watch_SOURCES = watch.c $(top_srcdir)/lib/strutils.c
|
||||
watch_LDADD = @NCURSES_LIBS@
|
||||
endif
|
||||
|
||||
kill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c
|
||||
|
15
watch.c
15
watch.c
@ -337,16 +337,11 @@ int main(int argc, char *argv[])
|
||||
option_exec = 1;
|
||||
break;
|
||||
case 'n':
|
||||
{
|
||||
char *str;
|
||||
interval = strtod(optarg, &str);
|
||||
if (!*optarg || *str)
|
||||
usage(stderr);
|
||||
if (interval < 0.1)
|
||||
interval = 0.1;
|
||||
if (interval > ~0u / 1000000)
|
||||
interval = ~0u / 1000000;
|
||||
}
|
||||
interval = strtod_or_err(optarg, _("failed to parse argument"));
|
||||
if (interval < 0.1)
|
||||
interval = 0.1;
|
||||
if (interval > ~0u / 1000000)
|
||||
interval = ~0u / 1000000;
|
||||
break;
|
||||
case 'p':
|
||||
precise_timekeeping = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user