gbranden pushed a commit to branch master
in repository groff.

commit 7af7a1be024bf285be161579f7b11f100b1ebd6c
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Oct 18 20:50:31 2026 -0500

    [troff]: Fix Savannah #68796.
    
    * src/roff/troff/input.cpp (define_color): Improve `defcolor` request
      argument validation.  Replace assert(3)ion that could be tripped by
      invalid characters in color identifier with skip of input line.  Throw
      warnings in category "missing" if second or third arguments are
      absent.
    
    Fixes <https://savannah.gnu.org/bugs/?68796>.
---
 ChangeLog                | 12 ++++++++++++
 src/roff/troff/input.cpp | 22 ++++++++++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 30a64d7e1..5df63704b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-10-18  G. Branden Robinson <[email protected]>
+
+       [troff]: Fix Savannah #68796.
+
+       * src/roff/troff/input.cpp (define_color): Improve `defcolor`
+       request argument validation.  Replace assert(3)ion that could be
+       tripped by invalid characters in color identifier with skip of
+       input line.  Throw warnings in category "missing" if second or
+       third arguments are absent.
+
+       Fixes <https://savannah.gnu.org/bugs/?68796>.
+
 2026-10-18  G. Branden Robinson <[email protected]>
 
        [groff]: Regression-test Savannah #68796.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index a5fc311a2..63883018e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1694,8 +1694,17 @@ static void define_color() // .defcolor
     return;
   }
   symbol color_name = read_long_identifier();
-  // Testing has_arg() should have ensured this.
-  assert(color_name != 0 /* nullptr */);
+  if (color_name.is_null()) {
+    // The identifier was garbage, like `a\&b`.
+    skip_line();
+    return;
+  }
+  if (!has_arg()) {
+    warning(WARN_MISSING, "color definition request"
+           " expects color space and channel value arguments");
+    skip_line();
+    return;
+  }
   if (color_name == default_symbol) {
     warning(WARN_COLOR, "default color cannot be redefined");
     skip_line();
@@ -1703,8 +1712,13 @@ static void define_color() // .defcolor
   }
   symbol color_space = read_long_identifier();
   if (color_space.is_null()) {
-    warning(WARN_MISSING, "missing color space in color definition"
-           " request");
+    // The identifier was garbage, like `a\&b`.
+    skip_line();
+    return;
+  }
+  if (!has_arg()) {
+    warning(WARN_MISSING, "color definition request"
+           " expects color channel value argument(s)");
     skip_line();
     return;
   }

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

Reply via email to