bugGNU roff - Bugs: bug #64240, [troff] make numeric expression...

 
 

bug #64240: [troff] make numeric expression parser more sensitive to nonsense

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Tue 23 May 2023 08:23:06 AM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Warning/Suspicious behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.24.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 20 Aug 2024 12:35:19 AM UTC, comment #6: 


commit 2bd122bf56ecb688a2612fade02643c9db27feef
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sat Aug 17 10:48:36 2024 -0500

    [troff]: Fix Savannah #64240 (warn of nr garbage).

    * src/roff/troff/reg.cpp (define_register): Warn when garbage
      encountered in numeric expression argument to `nr` request.

    Fixes <https://savannah.gnu.org/bugs/?64240>.


G. Branden Robinson <gbranden>
Group administrator
Sat 17 Aug 2024 03:46:16 PM UTC, comment #5: 


$ cat EXPERIMENTS/misleading-units.roff
.nr a 5in
.nr b 3cm
.nr c 9pt+3vee
.nr d 5i3c9p
$ ./build/test-groff -ww -T ascii EXPERIMENTS/misleading-units.roff
troff:EXPERIMENTS/misleading-units.roff:1: warning: expected end of line or an auto-increment argument in register definition request; got character 'n'
troff:EXPERIMENTS/misleading-units.roff:2: warning: expected end of line or an auto-increment argument in register definition request; got character 'm'
troff:EXPERIMENTS/misleading-units.roff:3: warning: expected end of line or an auto-increment argument in register definition request; got character 't'
troff:EXPERIMENTS/misleading-units.roff:4: warning: expected end of line or an auto-increment argument in register definition request; got character '3'


G. Branden Robinson <gbranden>
Group administrator
Sat 17 Aug 2024 03:44:33 PM UTC, comment #4: 

I must know the formatter better now.  This was easy.


diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index 7daf30912..57f10b5a7 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -323,8 +323,14 @@ void define_register()
       register_dictionary.define(nm, r);
     }
     r->set_value(v);
-    if (tok.is_space() && has_arg() && read_measurement(&v, 'u'))
-      r->set_increment(v);
+    if (tok.is_space()) {
+      if (has_arg() && read_measurement(&v, 'u'))
+       r->set_increment(v);
+    }
+    else if (has_arg() && !tok.is_tab())
+      warning(WARN_SYNTAX, "expected end of line or an auto-increment"
+             " argument in register definition request; got %1",
+             tok.description());
   }
   skip_line();
 }


G. Branden Robinson <gbranden>
Group administrator
Sat 17 Aug 2024 02:44:52 PM UTC, comment #3: 

Closed bug #64559 as a duplicate of this.  And we really, really, should be raising a diagnostic here, because...


$ nroff -ww > /dev/null
.nr a 1 2
\n+a
.tm a=\na
a=3
.nr b 1g 2
\n+b
.tm b=\nb
b=1
.ex


DWB and Heirloom Doctools _troff_s behave the same way.  But we really should throw a diagnostic since we're ignoring request argument.

G. Branden Robinson <gbranden>
Group administrator
Wed 16 Aug 2023 03:57:24 AM UTC, comment #2: 

Also see bug #64559.  Need root-cause analysis to determine if it's a duplicate.

G. Branden Robinson <gbranden>
Group administrator
Tue 23 May 2023 08:26:17 AM UTC, comment #1: 

Here's the mailing list thread.

G. Branden Robinson <gbranden>
Group administrator
Tue 23 May 2023 08:23:06 AM UTC, original submission:  


$ cat EXPERIMENTS/misleading-units.roff
.nr a 5in
.nr b 3cm
.nr c 9pt+3vee
.nr d 5i3c9p
$ nroff -ww EXPERIMENTS/misleading-units.roff


G. Branden Robinson <gbranden>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-08-20 gbranden Planned ReleaseNone 1.24.0
    2024-08-20 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2024-08-17 gbranden StatusNone In Progress
        Assigned toNone gbranden

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code