Forráskód Böngészése

parser/contact: cleaned log messages and safety check for invalid iterator call

Daniel-Constantin Mierla 11 éve
szülő
commit
c1feccdba8
1 módosított fájl, 10 hozzáadás és 5 törlés
  1. 10 5
      parser/contact/parse_contact.c

+ 10 - 5
parser/contact/parse_contact.c

@@ -134,7 +134,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 	contact_body_t* cb;
 
 	if (!msg) {
-		LOG(L_ERR, "contact_iterator: Invalid parameter value\n");
+		LOG(L_ERR, "Invalid parameter value\n");
 		return -1;
 	}
 
@@ -146,7 +146,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 		hdr = msg->contact;
 		if (!hdr) {
 			if (parse_headers(msg, HDR_CONTACT_F, 0) == -1) {
-				LOG(L_ERR, "contact_iterator: Error while parsing headers\n");
+				LOG(L_ERR, "Error while parsing headers\n");
 				return -1;
 			}
 
@@ -155,7 +155,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 
 		if (hdr) {
 			if (parse_contact(hdr) < 0) {
-				LOG(L_ERR, "contact_iterator: Error while parsing Contact\n");
+				LOG(L_ERR, "Error while parsing Contact\n");
 				return -1;
 			}
 		} else {
@@ -175,6 +175,11 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 			return 0;
 		}
 
+		if(hdr==NULL) {
+			LOG(L_ERR, "contact iterator not initialized\n");
+			return -1;
+		}
+
 		     /* Try to find and parse another Contact
 		      * header field
 		      */
@@ -193,7 +198,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 			      * part of the message header
 			      */
 			if (parse_headers(msg, HDR_CONTACT_F, 1) == -1) {
-				LOG(L_ERR, "contact_iterator: Error while parsing message header\n");
+				LOG(L_ERR, "Error while parsing message header\n");
 				return -1;
 			}
 			
@@ -212,7 +217,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 		}
 		
 		if (parse_contact(hdr) < 0) {
-			LOG(L_ERR, "contact_iterator: Error while parsing Contact HF body\n");
+			LOG(L_ERR, "Error while parsing Contact HF body\n");
 			return -1;
 		}