From 5ca605e59d70b1b3bb80ba54f7cc2b33dd16c998 Mon Sep 17 00:00:00 2001 From: op Date: Sun, 5 Apr 2026 23:17:30 +0000 Subject: [PATCH] fix crash on invalid tags file If the tag entry points to the line number zero, less crashes because internally it uses that line number to imply that the tag is associated with a pattern. issue reported by Henry Ford (henryfordkjv at gmail), thanks! ok kirill@ --- usr.bin/less/tags.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr.bin/less/tags.c b/usr.bin/less/tags.c index ddc8d6541df..34fcc87cbd6 100644 --- a/usr.bin/less/tags.c +++ b/usr.bin/less/tags.c @@ -260,6 +260,10 @@ findctag(char *tag) */ tagendline = 0; taglinenum = getnum(&p, 0, &err); + if (!err && taglinenum <= 0) { + /* line numbers must be positive */ + continue; + } if (err) { /* * No, it must be a pattern.