Quellcode durchsuchen

- warning and fixes (cfg.y $$=0 on error) merged from testing-0.8.12-r1
- pdt and mangler are now built by default (Makefile)

Andrei Pelinescu-Onciul vor 22 Jahren
Ursprung
Commit
b23a7a0073
6 geänderte Dateien mit 48 neuen und 31 gelöschten Zeilen
  1. 1 1
      Makefile
  2. 9 0
      cfg.y
  3. 35 28
      msg_translator.c
  4. 1 1
      pass_fd.c
  5. 1 1
      re.h
  6. 1 0
      test/th-uri-fast.cfg

+ 1 - 1
Makefile

@@ -43,7 +43,7 @@ skip_cfg_install?=
 skip_modules?=
 skip_modules?=
 
 
 # if not set on the cmd. line or the env, exclude this modules:
 # if not set on the cmd. line or the env, exclude this modules:
-exclude_modules?= 			cpl cpl-c ext extcmd mangler pdt \
+exclude_modules?= 			cpl cpl-c ext extcmd \
 							postgres snmp \
 							postgres snmp \
 							im radius_acc radius_auth \
 							im radius_acc radius_auth \
 							jabber mysql \
 							jabber mysql \

+ 9 - 0
cfg.y

@@ -1103,6 +1103,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 														$3,
 														$3,
 														0);
 														0);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1115,6 +1116,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															$3,
 															$3,
 															0);
 															0);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1127,6 +1129,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															(void*)$3,
 															(void*)$3,
 															0);
 															0);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1139,6 +1142,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															$3,
 															$3,
 															(void*)$5);
 															(void*)$5);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1151,6 +1155,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															$3,
 															$3,
 															(void*)$5);
 															(void*)$5);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1163,6 +1168,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															 (void*)$3,
 															 (void*)$3,
 															(void*)$5);
 															(void*)$5);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1175,6 +1181,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															0,
 															0,
 															0);
 															0);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1189,6 +1196,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															0,
 															0,
 															(void*)$5);
 															(void*)$5);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif
@@ -1201,6 +1209,7 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 															0,
 															0,
 															0);
 															0);
 										#else
 										#else
+											$$=0;
 											yyerror("tls support not "
 											yyerror("tls support not "
 													"compiled in");
 													"compiled in");
 										#endif
 										#endif

+ 35 - 28
msg_translator.c

@@ -1586,10 +1586,14 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 	struct lump_rpl   *lump;
 	struct lump_rpl   *lump;
 	struct lump_rpl   *body;
 	struct lump_rpl   *body;
 	int               i;
 	int               i;
-	str               received = {0,0};
-	str               rport = {0,0};
-	str               warning = {0,0};
-	str               content_len = {0,0};
+	char*             received_buf;
+	unsigned int      received_len;
+	char*             rport_buf;
+	unsigned int      rport_len;
+	char*             warning_buf;
+	unsigned int      warning_len;
+	char*             content_len_buf;
+	unsigned int      content_len_len;
 	unsigned int      text_len;
 	unsigned int      text_len;
 	char *after_body;
 	char *after_body;
 	str  to_tag;
 	str  to_tag;
@@ -1597,9 +1601,11 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 
 
 	body = 0;
 	body = 0;
 	buf=0;
 	buf=0;
-
+	received_buf=rport_buf=warning_buf=content_len_buf=0;
+	received_len=rport_len=warning_len=content_len_len=0;
+	
 	text_len=strlen(text);
 	text_len=strlen(text);
-
+	
 	/* force parsing all headers -- we want to return all
 	/* force parsing all headers -- we want to return all
 	Via's in the reply and they may be scattered down to the
 	Via's in the reply and they may be scattered down to the
 	end of header (non-block Vias are a really poor property
 	end of header (non-block Vias are a really poor property
@@ -1615,7 +1621,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 
 
 	/* check if received needs to be added */
 	/* check if received needs to be added */
 	if (received_test(msg)) {
 	if (received_test(msg)) {
-		if ((received.s=received_builder(msg,&received.len))==0) {
+		if ((received_buf=received_builder(msg,&received_len))==0) {
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
 				"alas, received_builder failed\n");
 				"alas, received_builder failed\n");
 			goto error00;
 			goto error00;
@@ -1624,7 +1630,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 	/* check if rport needs to be updated */
 	/* check if rport needs to be updated */
 	if ( (msg->msg_flags&FL_FORCE_RPORT)||
 	if ( (msg->msg_flags&FL_FORCE_RPORT)||
 		(msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){
 		(msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){
-		if ((rport.s=rport_builder(msg, &rport.len))==0){
+		if ((rport_buf=rport_builder(msg, &rport_len))==0){
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req:"
 			LOG(L_ERR, "ERROR: build_res_buf_from_sip_req:"
 							" rport_builder failed\n");
 							" rport_builder failed\n");
 			goto error01; /* free everything */
 			goto error01; /* free everything */
@@ -1652,7 +1658,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 			case HDR_VIA:
 			case HDR_VIA:
 				/* we always add CRLF to via*/
 				/* we always add CRLF to via*/
 				len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN;
 				len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN;
-				if (hdr==msg->h_via1) len += received.len+rport.len;
+				if (hdr==msg->h_via1) len += received_len+rport_len;
 				break;
 				break;
 			case HDR_RECORDROUTE:
 			case HDR_RECORDROUTE:
 				/* RR only for 1xx and 2xx replies */
 				/* RR only for 1xx and 2xx replies */
@@ -1676,14 +1682,14 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 		len += SERVER_HDR_LEN + CRLF_LEN;
 		len += SERVER_HDR_LEN + CRLF_LEN;
 	/* warning hdr */
 	/* warning hdr */
 	if (sip_warning) {
 	if (sip_warning) {
-		warning.s = warning_builder(msg,&warning.len);
-		if (warning.s) len += warning.len + CRLF_LEN;
+		warning_buf = warning_builder(msg,&warning_len);
+		if (warning_buf) len += warning_len + CRLF_LEN;
 		else LOG(L_WARN, "WARNING: warning skipped -- too big\n");
 		else LOG(L_WARN, "WARNING: warning skipped -- too big\n");
 	}
 	}
 	/* content length hdr */
 	/* content length hdr */
 	if (body) {
 	if (body) {
-		content_len.s = int2str(body->text.len, &content_len.len);
-		len += CONTENT_LENGTH_LEN + content_len.len + CRLF_LEN;
+		content_len_buf = int2str(body->text.len, (int*)&content_len_len);
+		len += CONTENT_LENGTH_LEN + content_len_len + CRLF_LEN;
 	} else {
 	} else {
 		len += CONTENT_LENGTH_LEN + 1/*0*/ + CRLF_LEN;
 		len += CONTENT_LENGTH_LEN + 1/*0*/ + CRLF_LEN;
 	}
 	}
@@ -1720,13 +1726,13 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 		{
 		{
 			case HDR_VIA:
 			case HDR_VIA:
 				if (hdr==msg->h_via1){
 				if (hdr==msg->h_via1){
-					if (rport.s){
+					if (rport_buf){
 						if (msg->via1->rport){ /* delete the old one */
 						if (msg->via1->rport){ /* delete the old one */
 							/* copy until rport */
 							/* copy until rport */
 							append_str_trans( p, hdr->name.s ,
 							append_str_trans( p, hdr->name.s ,
 								msg->via1->rport->start-hdr->name.s-1,msg);
 								msg->via1->rport->start-hdr->name.s-1,msg);
 							/* copy new rport */
 							/* copy new rport */
-							append_str(p, rport.s, rport.len);
+							append_str(p, rport_buf, rport_len);
 							/* copy the rest of the via */
 							/* copy the rest of the via */
 							append_str_trans(p, msg->via1->rport->start+
 							append_str_trans(p, msg->via1->rport->start+
 												msg->via1->rport->size, 
 												msg->via1->rport->size, 
@@ -1737,15 +1743,15 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 							/* normal whole via copy */
 							/* normal whole via copy */
 							append_str_trans( p, hdr->name.s , 
 							append_str_trans( p, hdr->name.s , 
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
-							append_str(p, rport.s, rport.len);
+							append_str(p, rport_buf, rport_len);
 						}
 						}
 					}else{
 					}else{
 						/* normal whole via copy */
 						/* normal whole via copy */
 						append_str_trans( p, hdr->name.s , 
 						append_str_trans( p, hdr->name.s , 
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
 								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
 					}
 					}
-					if (received.s)
-						append_str( p, received.s, received.len);
+					if (received_buf)
+						append_str( p, received_buf, received_len);
 				}else{
 				}else{
 					/* normal whole via copy */
 					/* normal whole via copy */
 					append_str_trans( p, hdr->name.s,
 					append_str_trans( p, hdr->name.s,
@@ -1808,17 +1814,17 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 		p+=CRLF_LEN;
 		p+=CRLF_LEN;
 	}
 	}
 	/* content_length hdr */
 	/* content_length hdr */
-	if (content_len.len) {
+	if (content_len_len) {
 		append_str( p, CONTENT_LENGTH, CONTENT_LENGTH_LEN);
 		append_str( p, CONTENT_LENGTH, CONTENT_LENGTH_LEN);
-		append_str( p, content_len.s, content_len.len );
+		append_str( p, content_len_buf, content_len_len );
 		append_str( p, CRLF, CRLF_LEN );
 		append_str( p, CRLF, CRLF_LEN );
 	} else {
 	} else {
 		append_str( p, CONTENT_LENGTH"0"CRLF,CONTENT_LENGTH_LEN+1+CRLF_LEN);
 		append_str( p, CONTENT_LENGTH"0"CRLF,CONTENT_LENGTH_LEN+1+CRLF_LEN);
 	}
 	}
 	/* warning header */
 	/* warning header */
-	if (warning.s) {
-		memcpy( p, warning.s, warning.len);
-		p+=warning.len;
+	if (warning_buf) {
+		memcpy( p, warning_buf, warning_len);
+		p+=warning_len;
 		memcpy( p, CRLF, CRLF_LEN);
 		memcpy( p, CRLF, CRLF_LEN);
 		p+=CRLF_LEN;
 		p+=CRLF_LEN;
 	}
 	}
@@ -1832,20 +1838,21 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 	}
 	}
 
 
 	if (len!=p-buf)
 	if (len!=p-buf)
-		LOG(L_CRIT,"BUGGGG!!!! diff len=%d p-buf=%d\n",len,p-buf);
+		LOG(L_CRIT,"BUG:build_res_from_sip_req: diff len=%d p-buf=%d\n",
+					len, (int)(p-buf));
 
 
 	*(p) = 0;
 	*(p) = 0;
 	*returned_len = len;
 	*returned_len = len;
 	/* in req2reply, received_buf is not introduced to lumps and
 	/* in req2reply, received_buf is not introduced to lumps and
 	   needs to be deleted here
 	   needs to be deleted here
 	*/
 	*/
-	if (received.s) pkg_free(received.s);
-	if (rport.s) pkg_free(rport.s);
+	if (received_buf) pkg_free(received_buf);
+	if (rport_buf) pkg_free(rport_buf);
 	return buf;
 	return buf;
 
 
 error01:
 error01:
-	if (received.s) pkg_free(received.s);
-	if (rport.s) pkg_free(rport.s);
+	if (received_buf) pkg_free(received_buf);
+	if (rport_buf) pkg_free(rport_buf);
 error00:
 error00:
 	*returned_len=0;
 	*returned_len=0;
 	return 0;
 	return 0;

+ 1 - 1
pass_fd.c

@@ -56,7 +56,7 @@ int recv_all(int socket, void* data, int data_len)
 	
 	
 	b_read=0;
 	b_read=0;
 	do{
 	do{
-		n=recv(socket, data+b_read, data_len-b_read, MSG_WAITALL);
+		n=recv(socket, (char*)data+b_read, data_len-b_read, MSG_WAITALL);
 		if (n<0){
 		if (n<0){
 			/* error */
 			/* error */
 			if (errno==EINTR) continue; /* signal, try again */
 			if (errno==EINTR) continue; /* signal, try again */

+ 1 - 1
re.h

@@ -63,7 +63,7 @@ struct subst_expr{
 
 
 struct replace_lst{
 struct replace_lst{
 	int offset;
 	int offset;
-	int size;   /* at offset, delete size bytes and replace them with rpl */;
+	int size;   /* at offset, delete size bytes and replace them with rpl */
 	str rpl;
 	str rpl;
 	struct replace_lst *next;
 	struct replace_lst *next;
 };
 };

+ 1 - 0
test/th-uri-fast.cfg

@@ -16,6 +16,7 @@
 check_via=no     # (cmd. line: -v)
 check_via=no     # (cmd. line: -v)
 dns=no          # (cmd. line: -r)
 dns=no          # (cmd. line: -r)
 rev_dns=no      # (cmd. line: -R)
 rev_dns=no      # (cmd. line: -R)
+mem_log=0
 #port=5070
 #port=5070
 #listen=127.0.0.1
 #listen=127.0.0.1
 #listen=195.37.77.101
 #listen=195.37.77.101