From: Sami Kerola Date: Wed, 21 Sep 2011 20:26:05 +0000 (+0200) Subject: flock: use strutils.h to check numeric user input X-Git-Tag: v2.21-rc1~356^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37bb0ce8129f0ff7a0d7ff0d8d5d6708bbf00277;p=thirdparty%2Futil-linux.git flock: use strutils.h to check numeric user input Signed-off-by: Sami Kerola --- diff --git a/sys-utils/Makefile.am b/sys-utils/Makefile.am index c05a0e7e3a..13c79c4dfb 100644 --- a/sys-utils/Makefile.am +++ b/sys-utils/Makefile.am @@ -40,6 +40,7 @@ rtcwake_SOURCES = rtcwake.c $(top_srcdir)/lib/strutils.c dmesg_SOURCES = dmesg.c $(top_srcdir)/lib/strutils.c ipcmk_SOURCES = ipcmk.c $(top_srcdir)/lib/strutils.c ipcrm_SOURCES = ipcrm.c $(top_srcdir)/lib/strutils.c +flock_SOURCES = flock.c $(top_srcdir)/lib/strutils.c if BUILD_MOUNTPOINT bin_PROGRAMS += mountpoint diff --git a/sys-utils/flock.c b/sys-utils/flock.c index 03eec365e1..cdfa6cfb17 100644 --- a/sys-utils/flock.c +++ b/sys-utils/flock.c @@ -41,6 +41,7 @@ #include "c.h" #include "nls.h" +#include "strutils.h" static void __attribute__((__noreturn__)) usage(int ex) { @@ -217,10 +218,7 @@ int main(int argc, char *argv[]) } } else if (optind < argc) { /* Use provided file descriptor */ - fd = (int)strtol(argv[optind], &eon, 10); - if (*eon || !argv[optind]) { - errx(EX_USAGE, _("bad number: %s"), argv[optind]); - } + fd = (int)strtol_or_err(argv[optind], "bad number"); } else { /* Bad options */ errx(EX_USAGE, _("requires file descriptor, file or directory"));