mainGNU M4 - Support: sr #104303, format in m4

 
 

sr #104303: format in m4

Submitter:  None
Submitted:  Thu 09 Jun 2005 05:54:26 AM UTC
   
 
Category:  None Priority:  7 - High
Severity:  6 - Security Status:  Done
Privacy:  Public Assigned to:  ericb
Originator Email:  -email is unavailable- Open/Closed:  Closed
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 21 Nov 2006 01:54:55 PM UTC, comment #2: 

Fixed in 1.4.5.

Eric Blake <ericb>
Group administrator
Thu 29 Jun 2006 01:37:18 PM UTC, comment #1: 

Confirmed.  Depending on whether configure detected ecvt (which POSIX has declared obsolete), we are either using ecvt to format ourselves (with the risk of doing it wrong, as you demonstrated), or overflowing a buffer and allowing execution of arbitrary code by letting sprintf do the formatting.  m4 1.4.5 will have a fix for this issue.

Eric Blake <ericb>
Group administrator
Thu 09 Jun 2005 05:54:26 AM UTC, original submission:  

hello,

i have come across something unexpected using 'format' with m4. i am wanting to just trim off the decimal portion of a number. however, when the 'trimmed' number ends with zeros these get removed as well. for example:

m4_format(`%.0f', 293408.883333)
m4_format(`%.0f', 293409.883333)
m4_format(`%.0f', 293499.883333)

which produces:

293409
29341
2935

so, the first line works fine. the second and third lines do not produce what i expected at all. i thought that maybe i had misunderstood the implementation of 'format', so i coded the above in c:

printf("%.0f\n", 293408.883333);
printf("%.0f\n", 293409.883333);
printf("%.0f\n", 293499.883333);

and in this case i get precisely what i wanted:

293409
293410
293500

furthermore, have a look at this:

format(`%.1f', 20.0)
format(`%.1f', 21.0)

produces:

20
21.0                                                                                  
this seems to me to be highly inconsistent.

i am using GNU m4 1.4.3.

best regards,
andrew collier.

Anonymous

 

(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

 

CC list is empty

 

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 7 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-11-21 ericb StatusConfirmed Done
    Open/ClosedOpen Closed
2006-06-29 ericb Severity3 - Normal 6 - Security
    StatusNone Confirmed
    Assigned toNone ericb
2006-06-29 ericb Priority5 - Normal 7 - High
2005-06-09 None Carbon-Copy- Added abcollier --AT-- yahoo --DOT-- com

Back to the top

Powered by Savane 3.13-bb6a.
Corresponding source code