From 783e1c7a52d57ee5393dcbceb1b5aec4c8bb3172 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Sat, 8 Dec 2018 17:05:23 +0000 Subject: Check lengths of various string inputs and act accordingly in extreme cases. --- telem.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'telem.lua') diff --git a/telem.lua b/telem.lua index 9646d84..9612a4b 100755 --- a/telem.lua +++ b/telem.lua @@ -130,9 +130,16 @@ function do_board() if string.len(board) > 18 then print("Board names must be 18 characters or less!") return + elseif string.len(board) == 0 then + print("New board cancelled.") + return end - io.write("Description? ") + io.write("Board topic? (Max 48 chars)") local desc = io.read() + if string.len(desc) > 48 then + print("Board topics must be 48 characters or less!") + return + end -- Create directory local board_dir = path.join(_BBS_ROOT, "boards", board) lfs.mkdir(board_dir) @@ -195,6 +202,9 @@ function do_new() if string.len(subject) > 48 then print("Thread subjects must be 48 characters or less!") return + elseif string.len(subject) == 0 then + print("New thread cancelled.") + return end -- Save body of post to temp file local filename = os.tmpname() -- cgit v1.2.3