Changeset 5336
- Timestamp:
- Jun 7, 2016 10:07:57 AM (8 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_auth.h
r4214 r5336 167 167 PJ_DECL_LIST_MEMBER(struct pjsip_cached_auth); 168 168 169 pj_pool_t *pool; /**< Pool for cached auth */ 169 170 pj_str_t realm; /**< Realm. */ 170 171 pj_bool_t is_proxy; /**< Server type (401/407) */ -
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r5176 r5336 1123 1123 #endif 1124 1124 1125 /** 1126 * Maximum size of pool allowed for auth client session in pjsip_regc. 1127 * After the size exceeds because of Digest authentication processing, 1128 * the pool is reset. 1129 * 1130 * Default is 20 kB 1131 */ 1132 #ifndef PJSIP_AUTH_CACHED_POOL_MAX_SIZE 1133 # define PJSIP_AUTH_CACHED_POOL_MAX_SIZE (20 * 1024) 1134 #endif 1125 1135 1126 1136 /***************************************************************************** -
pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
r4989 r5336 177 177 pj_lock_release(regc->lock); 178 178 } else { 179 pjsip_cached_auth *auth = NULL; 179 180 pjsip_tpselector_dec_ref(®c->tp_sel); 180 181 if (regc->last_transport) { … … 190 191 pj_lock_destroy(regc->lock); 191 192 regc->lock = NULL; 193 194 auth = regc->auth_sess.cached_auth.next; 195 while (auth != ®c->auth_sess.cached_auth) { 196 pjsip_endpt_release_pool(regc->endpt, auth->pool); 197 auth = auth->next; 198 } 199 192 200 pjsip_endpt_release_pool(regc->endpt, regc->pool); 193 201 } -
pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c
r5227 r5336 358 358 * Update authentication session with a challenge. 359 359 */ 360 static void update_digest_session( pj_pool_t *ses_pool, 361 pjsip_cached_auth *cached_auth, 360 static void update_digest_session( pjsip_cached_auth *cached_auth, 362 361 const pjsip_www_authenticate_hdr *hdr ) 363 362 { … … 366 365 if (!cached_auth->last_chal || pj_stricmp2(&hdr->scheme, "digest")) { 367 366 cached_auth->last_chal = (pjsip_www_authenticate_hdr*) 368 pjsip_hdr_clone( ses_pool, hdr);367 pjsip_hdr_clone(cached_auth->pool, hdr); 369 368 } else { 370 369 /* Only update if the new challenge is "significantly different" … … 383 382 { 384 383 cached_auth->last_chal = (pjsip_www_authenticate_hdr*) 385 pjsip_hdr_clone(ses_pool, hdr);384 pjsip_hdr_clone(cached_auth->pool, hdr); 386 385 } 387 386 } … … 394 393 /* Save the whole challenge */ 395 394 cached_auth->last_chal = (pjsip_www_authenticate_hdr*) 396 pjsip_hdr_clone( ses_pool, hdr);395 pjsip_hdr_clone(cached_auth->pool, hdr); 397 396 398 397 /* Create cnonce */ 399 pj_create_unique_string( ses_pool, &cached_auth->cnonce );398 pj_create_unique_string( cached_auth->pool, &cached_auth->cnonce ); 400 399 401 400 /* Initialize nonce-count */ … … 407 406 */ 408 407 if (cached_auth->realm.slen == 0) { 409 pj_strdup( ses_pool, &cached_auth->realm,408 pj_strdup(cached_auth->pool, &cached_auth->realm, 410 409 &hdr->challenge.digest.realm); 411 410 } … … 420 419 } else { 421 420 /* Server gives new nonce. */ 422 pj_strdup(ses_pool, &cached_auth->last_chal->challenge.digest.nonce, 421 pj_strdup(cached_auth->pool, 422 &cached_auth->last_chal->challenge.digest.nonce, 423 423 &hdr->challenge.digest.nonce); 424 424 /* Has the opaque changed? */ … … 426 426 &hdr->challenge.digest.opaque)) 427 427 { 428 pj_strdup( ses_pool,428 pj_strdup(cached_auth->pool, 429 429 &cached_auth->last_chal->challenge.digest.opaque, 430 430 &hdr->challenge.digest.opaque); … … 692 692 { 693 693 if (cached_auth) { 694 update_digest_session( sess_pool,cached_auth, hdr );694 update_digest_session( cached_auth, hdr ); 695 695 696 696 cnonce = &cached_auth->cnonce; … … 961 961 } 962 962 963 964 static void recreate_cached_auth_pool( pjsip_endpoint *endpt, 965 pjsip_cached_auth *auth ) 966 { 967 pj_pool_t *auth_pool = pjsip_endpt_create_pool(endpt, "regc_auth%p", 1024, 968 1024); 969 970 if (auth->realm.slen) { 971 pj_str_t realm; 972 pj_strdup(auth_pool, &realm, &auth->realm); 973 pj_strassign(&auth->realm, &realm); 974 } 975 976 if (auth->cnonce.slen) { 977 pj_str_t cnonce; 978 pj_strdup(auth_pool, &cnonce, &auth->cnonce); 979 pj_strassign(&auth->cnonce, &cnonce); 980 } 981 982 if (auth->last_chal) { 983 auth->last_chal = (pjsip_www_authenticate_hdr*) 984 pjsip_hdr_clone(auth_pool, auth->last_chal); 985 } 986 987 pjsip_endpt_release_pool(endpt, auth->pool); 988 auth->pool = auth_pool; 989 } 963 990 964 991 /* Process authorization challenge */ … … 1127 1154 break; 1128 1155 1129 hchal = (const pjsip_www_authenticate_hdr*) 1156 hchal = (const pjsip_www_authenticate_hdr*)hdr; 1130 1157 ++chal_cnt; 1131 1158 … … 1133 1160 * if not present. 1134 1161 */ 1135 cached_auth = find_cached_auth(sess, &hchal->challenge.common.realm 1162 cached_auth = find_cached_auth(sess, &hchal->challenge.common.realm); 1136 1163 if (!cached_auth) { 1137 cached_auth = PJ_POOL_ZALLOC_T( sess->pool, pjsip_cached_auth); 1138 pj_strdup( sess->pool, &cached_auth->realm, &hchal->challenge.common.realm); 1164 cached_auth = PJ_POOL_ZALLOC_T(sess->pool, pjsip_cached_auth); 1165 cached_auth->pool = pjsip_endpt_create_pool(sess->endpt, 1166 "regc_auth%p", 1167 1024, 1168 1024); 1169 pj_strdup(cached_auth->pool, &cached_auth->realm, 1170 &hchal->challenge.common.realm); 1139 1171 cached_auth->is_proxy = (hchal->type == PJSIP_H_PROXY_AUTHENTICATE); 1140 1172 # if (PJSIP_AUTH_HEADER_CACHING) … … 1143 1175 } 1144 1176 # endif 1145 pj_list_insert_before( &sess->cached_auth, cached_auth);1177 pj_list_insert_before(&sess->cached_auth, cached_auth); 1146 1178 } 1147 1179 … … 1149 1181 * authorization session. 1150 1182 */ 1151 status = process_auth( 1152 1183 status = process_auth(tdata->pool, hchal, tdata->msg->line.req.uri, 1184 tdata, sess, cached_auth, &hauth); 1153 1185 if (status != PJ_SUCCESS) 1154 1186 return status; 1187 1188 if (pj_pool_get_used_size(cached_auth->pool) > 1189 PJSIP_AUTH_CACHED_POOL_MAX_SIZE) 1190 { 1191 recreate_cached_auth_pool(sess->endpt, cached_auth); 1192 } 1155 1193 1156 1194 /* Add to the message. */
Note: See TracChangeset
for help on using the changeset viewer.