Browse code

fixed Content-Lenght bug in build_res_buf_with_body_from_sip_req.

Raphael Coeffic authored on 26/03/2003 20:26:09
Showing 3 changed files
... ...
@@ -889,11 +889,12 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
889 889
 	char              *warning;
890 890
 	unsigned int      warning_len;
891 891
 	unsigned int	  text_len;
892
-	int r;
893
-	int content_len_len;
892
+	int  r;
893
+	int  content_len_len;
894 894
 	char *content_len;
895
+	char content_len_buf[MAX_CONTENT_LEN_BUF];
895 896
 	char *after_body;
896
-	str to_tag;
897
+	str  to_tag;
897 898
 	char *totags;
898 899
 
899 900
 	received_buf=0;
... ...
@@ -988,8 +989,10 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
988 988
 
989 989
 	if (body_len) {
990 990
 		content_len=int2str(body_len, &content_len_len);
991
+		memcpy(content_len_buf,content_len,content_len_len+1);
992
+		content_len = content_len_buf;
991 993
 		len += CONTENT_LENGTH_LEN + content_len_len + CRLF_LEN;
992
-	    len += body_len;
994
+		len += body_len;
993 995
 	} else {
994 996
 		len +=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
995 997
 	}
... ...
@@ -42,6 +42,8 @@
42 42
 #define WARNING_PHRASE " \"Noisy feedback tells: "
43 43
 #define WARNING_PHRASE_LEN (sizeof(WARNING_PHRASE)-1)
44 44
 
45
+#define MAX_CONTENT_LEN_BUF INT2STR_MAX_LEN /* see ut.h/int2str() */
46
+
45 47
 #include "parser/msg_parser.h"
46 48
 #include "ip_addr.h"
47 49
 
... ...
@@ -148,11 +148,12 @@ static inline int btostr( char *p,  unsigned char val)
148 148
 }
149 149
 
150 150
 
151
+#define INT2STR_MAX_LEN 11 /* 10 digits + 0 */
151 152
 
152 153
 /* returns a pointer to a static buffer containing l in asciiz & sets len */
153 154
 static inline char* int2str(unsigned int l, int* len)
154 155
 {
155
-	static char r[11]; /* 10 digits + 0 */
156
+	static char r[INT2STR_MAX_LEN];
156 157
 	int i;
157 158
 	
158 159
 	i=9;