]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
flock: keep -E exit status more restrictive
authorKarel Zak <kzak@redhat.com>
Mon, 9 Nov 2020 09:53:23 +0000 (10:53 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 13 Nov 2020 11:37:03 +0000 (12:37 +0100)
Addresses: https://github.com/karelzak/util-linux/issues/1180
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/flock.1
sys-utils/flock.c

index 20975f82c2d4ce3258059546e550509edf9c91ae..5235f83039d71a3636b11c5c9531e36e2beb17f3 100644 (file)
@@ -68,6 +68,7 @@ Pass a single \fIcommand\fR, without arguments, to the shell with
 The exit status used when the \fB\-n\fP option is in use, and the
 conflicting lock exists, or the \fB\-w\fP option is in use,
 and the timeout is reached.  The default value is \fB1\fR.
+The \fInumber\fR has to be in the range of 0 to 255.
 .TP
 .BR \-F , " \-\-no\-fork"
 Do not fork before executing
@@ -132,7 +133,8 @@ or
 .B \-w
 which report a failure to acquire the lock with a exit status given by the
 .B \-E
-option, or 1 by default.
+option, or 1 by default.  The exit status given by
+.B \-E has to be in the range of 0 to 255.
 .PP
 When using the \fIcommand\fR variant, and executing the child worked, then
 the exit status is that of the child command.
index 8dddebefd57734c362dd4789352e12edb42db181..670839c1d0d73dfd8e0d65527cdc0f6c57194ddd 100644 (file)
@@ -212,6 +212,8 @@ int main(int argc, char *argv[])
                case 'E':
                        conflict_exit_code = strtos32_or_err(optarg,
                                _("invalid exit code"));
+                       if (conflict_exit_code < 0 || conflict_exit_code > 255)
+                               errx(EX_USAGE, _("exit code out of range (expected 0 to 255)"));
                        break;
                case OPT_VERBOSE:
                        verbose = 1;