bugAVR C Runtime Library - Bugs: bug #43442, sprintf function incorrectly...

 
 

bug #43442: sprintf function incorrectly interprets format parameters

Submitted by:  None
Submitted on:  Sun 19 Oct 2014 10:00:12 PM UTC  
 
Category: LibrarySeverity: 3 - Normal
Priority: 5 - NormalItem Group: libc code
Status: InvalidPercent Complete: 0%
Assigned to: NoneOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 1.8.0
Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 19 Oct 2014 10:54:34 PM UTC, comment #1:

Problem solved - it was caused by variables that were in BCD format.

Anonymous
Sun 19 Oct 2014 10:00:12 PM UTC, original submission:

Function sprintf incorrectly interprets passed parameters, on following example:

char someString[3];
uint8_t number = 0;

number = 9;
sprintf(someString, "%02u", number);

Now in someString we will have 09 but when we do this:

number = 10;
sprintf(someString, "%02u", number);

Then in someString we have 16, not 10 as we expect. But when we change format from "%02u" to "%02x" then it works fine, and we have 10 in someString. Of course with values 20, 30 and so on problem also exist. From what I can see, this function interpret %u as hex(10 in HEX is 16 in DEC) and %x as decimal but it should be interpreted inversely.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Updated the item)
  • -unavailable- added by None (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 20 Oct 2014 09:15:19 AM UTCjoerg_wunschStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1