Update of bug #68787 (group groff):

         Planned Release:                    None => 1.25.0
                 Summary: [troff] `lf` request could validate its arguments
better => [PATCH] [troff] `lf` request could validate its arguments better

    _______________________________________________________

Follow-up Comment #1:


commit 0acd8cc10784f36c2bce6ce8b11bf8d7978d86d1
Author: G. Branden Robinson <[email protected]>
Date:   Sat Oct 17 09:13:35 2026 -0500

    XXX [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>.

diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 1fee5444e..40ffc2ecb 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -23658,6 +23658,9 @@
 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 a9bb16a6e..8da468ec1 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7232,12 +7232,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 @@ .SH Warnings
 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;




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68787>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to