From da406c0a793ce998e982dd88e46072002bd0e22c Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Sun, 13 Mar 2022 01:18:44 -0700
Subject: [PATCH] Fix CID 33235: Argument cannot be negative

---
 src/sbbs3/writemsg.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp
index 5c34346023..f06d8fc76d 100644
--- a/src/sbbs3/writemsg.cpp
+++ b/src/sbbs3/writemsg.cpp
@@ -1278,7 +1278,7 @@ bool sbbs_t::editfile(char *fname, bool msg)
 	}
 	if((file=nopen(fname,O_RDONLY))!=-1) {
 		length=(long)filelength(file);
-		if(length>(long)maxlines*MAX_LINE_LEN) {
+		if(length < 0 || length>(long)maxlines*MAX_LINE_LEN) {
 			close(file);
 			free(buf); 
 			attr(cfg.color[clr_err]);
-- 
GitLab