Browse code

select_list() function must not return the global class when the global flag is not set. Fixes SER-368

Miklos Tirpak authored on 26/03/2008 09:47:18
Showing 1 changed files
... ...
@@ -128,9 +128,11 @@ static avp_list_t* select_list(avp_flags_t flags)
128 128
 		} else {
129 129
 			return crt_list[IDX_FROM_DOMAIN];
130 130
 		}
131
+	} else if (flags & AVP_CLASS_GLOBAL) {
132
+		return *crt_glist;
131 133
 	}
132 134
 
133
-	return *crt_glist;
135
+	return NULL;
134 136
 }
135 137
 
136 138
 inline static avp_id_t compute_ID( str *name )
... ...
@@ -256,7 +258,8 @@ int add_avp(avp_flags_t flags, avp_name_t name, avp_value_t val)
256 258
 	      */
257 259
 	if ((flags & AVP_CLASS_ALL) == 0) flags |= AVP_CLASS_URI;
258 260
 	if ((flags & AVP_TRACK_ALL) == 0) flags |= AVP_TRACK_FROM;
259
-	list = select_list(flags);
261
+	if (!(list = select_list(flags)))
262
+		return -1;
260 263
 
261 264
 	if (flags & AVP_CLASS_URI) avp_class = AVP_CLASS_URI;
262 265
 	else if (flags & AVP_CLASS_USER) avp_class = AVP_CLASS_USER;
... ...
@@ -352,7 +355,10 @@ inline void get_avp_val(avp_t *avp, avp_value_t *val)
352 355
 /* Return the current list of user attributes */
353 356
 avp_list_t get_avp_list(avp_flags_t flags)
354 357
 {
355
-	return *select_list(flags);
358
+	avp_list_t *list;
359
+
360
+	list = select_list(flags);
361
+	return (list ? *list : NULL);
356 362
 }
357 363
 
358 364
 
... ...
@@ -447,7 +453,8 @@ avp_t *search_avp (avp_ident_t ident, avp_value_t* val, struct search_state* sta
447 453
 		}
448 454
 	}
449 455
 
450
-	list = select_list(ident.flags);
456
+	if (!(list = select_list(ident.flags)))
457
+		return NULL;
451 458
 
452 459
 	state->flags = ident.flags;
453 460
 	state->avp = *list;
... ...
@@ -470,6 +477,7 @@ avp_t *search_next_avp(struct search_state* s, avp_value_t *val )
470 477
 {
471 478
 	int matched;
472 479
 	avp_t* avp;
480
+	avp_list_t *list;
473 481
 
474 482
 	if (s == 0) {
475 483
 		LOG(L_ERR, "search_next:avp: Invalid parameter value\n");
... ...
@@ -502,17 +510,19 @@ avp_t *search_next_avp(struct search_state* s, avp_value_t *val )
502 510
 
503 511
 		if (s->flags & AVP_CLASS_URI) {
504 512
 			s->flags &= ~AVP_CLASS_URI;
505
-			s->avp = *select_list(s->flags);
513
+			list = select_list(s->flags);
506 514
 		} else if (s->flags & AVP_CLASS_USER) {
507 515
 			s->flags &= ~AVP_CLASS_USER;
508
-			s->avp = *select_list(s->flags);
516
+			list = select_list(s->flags);
509 517
 		} else if (s->flags & AVP_CLASS_DOMAIN) {
510 518
 			s->flags &= ~AVP_CLASS_DOMAIN;
511
-			s->avp = *select_list(s->flags);
519
+			list = select_list(s->flags);
512 520
 		} else {
513 521
 			s->flags &= ~AVP_CLASS_GLOBAL;
514 522
 			return 0;
515 523
 		}
524
+		if (!list) return 0;
525
+		s->avp = *list;
516 526
 	}
517 527
 
518 528
 	return 0;