This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH] itoa


Hi Corinna,

> What other platforms?

Various Windows compilers and a variety of embedded targets, but no, not generally unices (although you often see people asking for it in various forums).

> The API is rather unsafe, given that the size of the buffer is not checked (no size parameter).  

The API is that the buffer should be sizeof(int)*8+1 to handle the worst case.  E.g: http://www.cplusplus.com/reference/cstdlib/itoa/ I've added this to the DESCRIPTION.

> But what I'm really missing are checks for the base parameter being valid.  It could be > 36.  Or negative.

According to the docs, base must be between 2 and 36. I didn't add this check initially, as I don't see much parameter range checking in newlib generally, however, I've now added a check and it terminates the string and returns NULL if base is out of range. (It seems MSVC doesn't check the base, as it divides by zero if you use 0).

I've also modified it as per Freddie's suggestion.

Cheers,
Jon

Attachment: itoa2.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]