gbranden pushed a commit to branch master
in repository groff.

commit 1365df2b4497d4d552c8a9a8b33218fa0972903f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Oct 17 09:13:35 2026 -0500

    [troff]: Improve `lf` request input validation.
    
    * src/roff/troff/input.cpp (line_file): Throw warning in category
      "missing" if request is given no arguments.  Throw warning in category
      "syntax" if an empty interpolation is given as the second (file name)
      argument.
    
    * doc/groff.texi.in (Warnings):
    * src/roff/troff/troff.1.man (Warnings): Document it.
    
    Fixes <https://savannah.gnu.org/bugs/?68787>.
---
 ChangeLog                  | 14 ++++++++++++++
 doc/groff.texi.in          |  3 +++
 src/roff/troff/input.cpp   | 13 ++++++++++++-
 src/roff/troff/troff.1.man |  3 +++
 4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 168c14813..7955607f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2026-10-17  G. Branden Robinson <[email protected]>
+
+       [troff]: Improve `lf` request input validation.
+
+       * src/roff/troff/input.cpp (line_file): Throw warning in
+       category "missing" if request is given no arguments.  Throw
+       warning in category "syntax" if an empty interpolation is given
+       as the second (file name) argument.
+
+       * doc/groff.texi.in (Warnings):
+       * src/roff/troff/troff.1.man (Warnings): Document it.
+
+       Fixes <https://savannah.gnu.org/bugs/?68787>.
+
 2026-10-17  G. Branden Robinson <[email protected]>
 
        [troff]: Improve diagnostic messages.
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index c92d20de6..6d64dde5a 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -23658,6 +23658,9 @@ an empty or incomplete numeric expression was 
encountered;
 an operand to a numeric operator was missing;
 an attempt was made to format characters or spaces on an input line
 after an output line continuation escape sequence;
+an empty interpolation was supplied as the file name argument to the
+@code{lf}
+request;
 a recognized but inapposite escape sequence
 or unprintable character
 was employed in a device extension command;
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 242a7334a..c6508f713 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7241,12 +7241,23 @@ static int get_file_line(const char **filename, int 
*lineno)
 
 static void line_file() // .lf
 {
+  if (!has_arg()) {
+    warning(WARN_MISSING, "line and file name configuration request"
+           " expects at least one argument");
+    skip_line();
+    return;
+  }
   int n;
   if (read_integer(&n)) {
     if (has_arg(true /* peeking */)) {
       const char *reported_file_name = read_rest_of_line_as_argument();
+      if (reported_file_name != 0 /* nullptr */)
+       ; // TODO: Add `reported_file_name` to file name set.
+      else
+       warning(WARN_SYNTAX, "ignoring empty file name argument"
+               " to line and file name configuration request");
       (void) input_stack::set_location(reported_file_name, (n - 1));
-      // TODO: Add `reported_file_name` to file name set.
+      // No skip_line() here; we called read_rest_of_line_as_argument().
       tok.next();
       return;
     }
diff --git a/src/roff/troff/troff.1.man b/src/roff/troff/troff.1.man
index 927e91972..5bef582ee 100644
--- a/src/roff/troff/troff.1.man
+++ b/src/roff/troff/troff.1.man
@@ -868,6 +868,9 @@ an empty or incomplete numeric expression was encountered;
 an operand to a numeric operator was missing;
 an attempt was made to format characters or spaces on an input line
 after an output line continuation escape sequence;
+an empty interpolation was supplied as the file name argument to the
+.B lf
+request;
 a recognized but inapposite escape sequence
 or unprintable character
 was employed in a device extension command;

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to