summaryrefslogtreecommitdiff
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2009-03-11 12:49:50 +0100
committerKarel Zak <kzak@redhat.com>2009-03-11 13:37:40 +0100
commit841f86dbc2e35166fd43341c8eb144680b0c7ece (patch)
treea7d5eba010424d68af19264e8c42c517b38a6e38 /sys-utils
parentdcb54fafb128ab41772ae217afc6a7612e2cc446 (diff)
downloadutil-linux-old-841f86dbc2e35166fd43341c8eb144680b0c7ece.tar.gz
flockc: segfaults when file name is not given
$ flock -s Segmentation fault ltrace: __libc_start_main(0x8048870, 2, 0xbfe9f404, 0x8049070, 0x8049060 <unfinished ...> getopt_long(2, 0xbfe9f404, "+sexnouw:hV?", 0x80494e0, 0xbfe9f354) = 115 getopt_long(2, 0xbfe9f404, "+sexnouw:hV?", 0x80494e0, 0xbfe9f354) = -1 strtol(0, 0xbfe9f34c, 10, 0x80494e0, 0xbfe9f354 <unfinished ...> --- SIGSEGV (Segmentation fault) --- +++ killed by SIGSEGV +++ Addresses-Red-Had-Bugzilla: #489672 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/flock.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys-utils/flock.c b/sys-utils/flock.c
index 029e4364..3386e15b 100644
--- a/sys-utils/flock.c
+++ b/sys-utils/flock.c
@@ -217,7 +217,7 @@ int main(int argc, char *argv[])
EX_NOINPUT);
}
- } else {
+ } else if (optind < argc) {
/* Use provided file descriptor */
fd = (int)strtol(argv[optind], &eon, 10);
@@ -226,8 +226,15 @@ int main(int argc, char *argv[])
exit(EX_USAGE);
}
+ } else {
+ /* Bad options */
+
+ fprintf(stderr, "%s: requires file descriptor, file or directory\n",
+ program);
+ exit(EX_USAGE);
}
+
if ( have_timeout ) {
if ( timeout.it_value.tv_sec == 0 &&
timeout.it_value.tv_usec == 0 ) {