In testing leave, I found it accepts "12" and will alarm at 00:12, which is
probably not desirable. this check thats the specified time has 4 digits so
that the hour/minute math works properly.
Index: leave.c
===================================================================
RCS file: /home/cvs/src/usr.bin/leave/leave.c,v
retrieving revision 1.19
diff -u -p -r1.19 leave.c
--- leave.c 10 Feb 2018 00:00:47 -0000 1.19
+++ leave.c 22 Jan 2020 02:13:03 -0000
@@ -35,6 +35,7 @@
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
static __dead void usage(void);
@@ -83,6 +84,9 @@ main(int argc, char *argv[])
plusnow = 1;
++cp;
}
+
+ if (strlen(cp) != 4)
+ usage();
for (hours = 0; (c = *cp) && c != '\n'; ++cp) {
if (!isdigit((unsigned char)c))