|
@@ -294,10 +294,15 @@ static inline char* int2str_base(unsigned int l, int* len, int base)
|
|
|
|
|
|
/* print int to asciiz in a string buffer
|
|
/* print int to asciiz in a string buffer
|
|
* - be sure result buffer is at least INT2STR_MAX_LEN in size */
|
|
* - be sure result buffer is at least INT2STR_MAX_LEN in size */
|
|
-static inline char* int2strbuf(unsigned int l, char *r, int* len)
|
|
|
|
|
|
+static inline char* int2strbuf(unsigned int l, char *r, int r_size, int* len)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ if(unlikely(r_size<INT2STR_MAX_LEN)) {
|
|
|
|
+ if (len)
|
|
|
|
+ *len = 0;
|
|
|
|
+ return 0; /* => if someone misuses it => crash (feature no. 1) */
|
|
|
|
+ }
|
|
i=INT2STR_MAX_LEN-2;
|
|
i=INT2STR_MAX_LEN-2;
|
|
r[INT2STR_MAX_LEN-1]=0; /* null terminate */
|
|
r[INT2STR_MAX_LEN-1]=0; /* null terminate */
|
|
do{
|
|
do{
|
|
@@ -316,7 +321,7 @@ extern char ut_buf_int2str[INT2STR_MAX_LEN];
|
|
/* returns a pointer to a static buffer containing l in asciiz & sets len */
|
|
/* returns a pointer to a static buffer containing l in asciiz & sets len */
|
|
static inline char* int2str(unsigned long l, int* len)
|
|
static inline char* int2str(unsigned long l, int* len)
|
|
{
|
|
{
|
|
- return int2strbuf(l, ut_buf_int2str, len);
|
|
|
|
|
|
+ return int2strbuf(l, ut_buf_int2str, INT2STR_MAX_LEN, len);
|
|
}
|
|
}
|
|
|
|
|
|
/* Signed INTeger-TO-STRing: convers a long to a string
|
|
/* Signed INTeger-TO-STRing: convers a long to a string
|