exit on overlong passed data

This commit is contained in:
fordprefect
2021-01-08 16:41:23 +01:00
parent 76db34d3e4
commit 482f0379b5

View File

@@ -30,6 +30,13 @@ if os.path.getsize(database) < 100 * 1024 * 1024:
# only add entries if file size does not exceed 100 MiB
if "ort" in args and "name" in args and "comment" in args:
# fail if input is too long
if max(map(len, list(args[i] for i in args))) > 200:
# overlong input is a clear indication someone is fiddling with the interface
# this deserves no proper exit message
exit()
# add entry
try:
zeit = datetime.timestamp(datetime(int(args["year"]), int(args["month"]), int(args["day"]), int(args["hour"]), int(args["minute"])))