浏览代码

lib/ims: fixed possible crash when trying to get IMPI without realm

jaybeepee 10 年之前
父节点
当前提交
807160c199
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      lib/ims/ims_getters.c

+ 12 - 0
lib/ims/ims_getters.c

@@ -122,6 +122,15 @@ str cscf_get_private_identity(struct sip_msg *msg, str realm) {
 	struct hdr_field* h = 0;
 	int ret, i, res;
 
+	if ((parse_headers(msg, HDR_AUTHORIZATION_F, 0) != 0) && (parse_headers(msg, HDR_PROXYAUTH_F, 0) != 0)) {
+		return pi;
+	}
+
+	h = msg->authorization;
+	if (!msg->authorization) {
+		goto fallback;
+	}
+		
 	if (realm.len && realm.s) {
 		ret = find_credentials(msg, &realm, HDR_AUTHORIZATION_F, &h);
 		if (ret < 0) {
@@ -140,6 +149,9 @@ str cscf_get_private_identity(struct sip_msg *msg, str realm) {
 			}
 		}
 	}
+	
+	if (!h)
+		goto fallback;
 
 	res = parse_credentials(h);
 	if (res != 0) {