nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix an rcfile out-of-bounds read on empty lines


From: Saagar Jha
Subject: [PATCH] Fix an rcfile out-of-bounds read on empty lines
Date: Sun, 16 Feb 2020 04:12:14 -0800

Hi,

This is just a minor out-of-bounds fix in parse_rcfile.

Regards,
Saagar Jha

From ec66cf1b91ceed37344f9bc2d1c6eab6a343ec0b Mon Sep 17 00:00:00 2001
From: Saagar Jha <address@hidden>
Date: Sun, 16 Feb 2020 04:04:11 -0800
Subject: [PATCH] Fix an rcfile out-of-bounds read on empty lines

---
 src/rcfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c
index 5213e277..39387a22 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -1318,9 +1318,9 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool 
intros_only)
                        continue;
 #endif
                /* Strip the terminating newline and possibly a carriage 
return. */
-               if (buffer[length - 1] == '\n')
+               if (length && buffer[length - 1] == '\n')
                        buffer[--length] = '\0';
-               if (buffer[length - 1] == '\r')
+               if (length && buffer[length - 1] == '\r')
                        buffer[--length] = '\0';
 
                ptr = buffer;
-- 
2.25.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]