On 2/2/10 2:26 PM, Andrei Pelinescu-Onciul wrote:
On Feb 02, 2010 at 13:25, Daniel-Constantin
Mierla<miconda(a)gmail.com> wrote:
Module: sip-router
Branch: kamailio_3.0
Commit: 229496c7170bcc85f517a4985f7ab4bad553c8d3
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=229496c…
Author: Daniel-Constantin Mierla<miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla<miconda(a)gmail.com>
Date: Tue Feb 2 13:23:03 2010 +0100
core: use one buffer for int2str
- static declaration inside ut.h function results in hard copy to many
places, affecting acc detection of int to str conversions in buffer
- reported by Alex Balashov
---
[...]
-/* returns a pointer to a static buffer
containing l in asciiz& sets len */
-static inline char* int2str(unsigned int l, int* len)
+/* print int to asciiz in a string buffer
+ * - be sure result buffer is at least INT2STR_MAX_LEN in size */
+static inline char* int2strbuf(unsigned int l, char *r, int* len)
I think adding another parameter for the buffer length would be better
(read way safer) then relying on the caller providing a large enough
buffer.
thanks for suggestion, applied. Should be included in trunk? I don't
think there are side effects to any ser modules.
Daniel
E.g.:
static inline char*
int2strbuf(unsigned int l, char *r, int buf_len, int* res_len)
and
if (unlikely(buf_len<INT2STR_MAX_LEN)){
*res_len=0;
return 0; /* => if someone missuses it => crash */
}
+
{
- static char r[INT2STR_MAX_LEN];
int i;
i=INT2STR_MAX_LEN-2;
@@ -312,6 +312,13 @@ static inline char* int2str(unsigned int l, int* len)
return&r[i+1];
}
[...]
Andrei
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla
eLearning class for Kamailio 3.0.0
Starting Feb 8, 2010
*
http://www.asipto.com/