Browse code

- hopefully fixed the sip_msg_cloner mem. bug - more strict mem. checking when compiling with DBG_QM_MALLOC (might catch other off by 1-7 alloc. boundary violations)

Andrei Pelinescu-Onciul authored on 08/11/2002 16:16:09
Showing 4 changed files
... ...
@@ -7,7 +7,7 @@
7 7
 #version number
8 8
 VERSION = 0
9 9
 PATCHLEVEL = 8
10
-SUBLEVEL =   10-pre3
10
+SUBLEVEL =   10-pre4
11 11
 EXTRAVERSION = 
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
... ...
@@ -134,7 +134,8 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
134 134
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
135 135
 	 -DDNS_IP_HACK \
136 136
 	 -DUSE_IPV6 \
137
-	 -DF_MALLOC \
137
+	 -DDBG_QM_MALLOC \
138
+	 #-DF_MALLOC \
138 139
 	 #-DNO_DEBUG \
139 140
 	 #-DNO_LOG
140 141
 	 #-DEXTRA_DEBUG \
... ...
@@ -1,6 +1,6 @@
1 1
 /* $Id$
2 2
  *
3
- * simple, very fast, & dummy malloc library
3
+ * simple, very fast, malloc library
4 4
  *
5 5
  * Copyright (C) 2001-2003 Fhg Fokus
6 6
  *
... ...
@@ -33,11 +33,14 @@
33 33
 
34 34
 
35 35
 /* defs*/
36
-
37
-#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
38
-						 sizeof(qm_frag)+sizeof(qm_frag_end)
39
-						 must be mutliple of ROUNDTO!
40
-					   */
36
+#ifdef DBG_QM_MALLOC
37
+	#define ROUDNTO		 4 /* minimum possible ROUNDTO ->heavy debugging*/
38
+#else
39
+	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
40
+							 sizeof(qm_frag)+sizeof(qm_frag_end)
41
+							 must be mutliple of ROUNDTO!
42
+						   */
43
+#endif
41 44
 #define MIN_FRAG_SIZE	ROUNDTO
42 45
 
43 46
 
... ...
@@ -192,11 +192,21 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
192 192
 						len+=ROUND4(sizeof(struct via_param ));
193 193
 				}
194 194
 				break;
195
-			case HDR_PROXYAUTH:
196
-				/* we frequently parse this HF but don't use it in TM --
197
-				   just keep silent about it
198
-				*/
195
+			
196
+			case HDR_CALLID:
197
+			case HDR_FROM:
198
+			case HDR_CONTACT:
199
+			case HDR_MAXFORWARDS:
200
+			case HDR_ROUTE:
201
+			case HDR_RECORDROUTE:
202
+			case HDR_CONTENTTYPE:
203
+			case HDR_CONTENTLENGTH:
204
+			case HDR_PROXYREQUIRE:
205
+			case HDR_UNSUPPORTED:
206
+			case HDR_ALLOW:
207
+				/* we ignore them for now even if they have something parsed*/
199 208
 				break;
209
+
200 210
 			default:
201 211
 				if (hdr->parsed) {
202 212
 					LOG(L_WARN, "WARNING: sip_msg_cloner: "
... ...
@@ -231,7 +241,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
231 241
 
232 242
 	/*length of reply lump structures*/
233 243
 	for(rpl_lump=org_msg->reply_lump;rpl_lump;rpl_lump=rpl_lump->next)
234
-		len+=rpl_lump->text.len;
244
+			len+=ROUND4(sizeof(struct lump_rpl))+ROUND4(rpl_lump->text.len);
235 245
 
236 246
 	p=(char *)shm_malloc(len);foo=p;
237 247
 	if (!p)
... ...
@@ -504,10 +514,10 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
504 514
 	for(rpl_lump=org_msg->reply_lump;rpl_lump;rpl_lump=rpl_lump->next)
505 515
 	{
506 516
 		*(rpl_lump_anchor)=(struct lump_rpl*)p;
507
-		p+=sizeof( struct lump_rpl );
517
+		p+=ROUND4(sizeof( struct lump_rpl ));
508 518
 		(*rpl_lump_anchor)->text.len = rpl_lump->text.len;
509 519
 		(*rpl_lump_anchor)->text.s=p;
510
-		p+=rpl_lump->text.len;
520
+		p+=ROUND4(rpl_lump->text.len);
511 521
 		memcpy((*rpl_lump_anchor)->text.s,rpl_lump->text.s,rpl_lump->text.len);
512 522
 		(*rpl_lump_anchor)->next=0;
513 523
 		rpl_lump_anchor = &((*rpl_lump_anchor)->next);