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 256
 	      */
257 257
 	if ((flags & AVP_CLASS_ALL) == 0) flags |= AVP_CLASS_URI;
258 258
 	if ((flags & AVP_TRACK_ALL) == 0) flags |= AVP_TRACK_FROM;
259
-	list = select_list(flags);
259
+	if (!(list = select_list(flags)))
260
+		return -1;
260 261
 
261 262
 	if (flags & AVP_CLASS_URI) avp_class = AVP_CLASS_URI;
262 263
 	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 352
 /* Return the current list of user attributes */
353 353
 avp_list_t get_avp_list(avp_flags_t flags)
354 354
 {
355
-	return *select_list(flags);
355
+	avp_list_t *list;
356
+
357
+	list = select_list(flags);
358
+	return (list ? *list : NULL);
356 359
 }
357 360
 
358 361
 
... ...
@@ -447,7 +453,8 @@ avp_t *search_avp (avp_ident_t ident, avp_value_t* val, struct search_state* sta
447 447
 		}
448 448
 	}
449 449
 
450
-	list = select_list(ident.flags);
450
+	if (!(list = select_list(ident.flags)))
451
+		return NULL;
451 452
 
452 453
 	state->flags = ident.flags;
453 454
 	state->avp = *list;
... ...
@@ -470,6 +477,7 @@ avp_t *search_next_avp(struct search_state* s, avp_value_t *val )
470 470
 {
471 471
 	int matched;
472 472
 	avp_t* avp;
473
+	avp_list_t *list;
473 474
 
474 475
 	if (s == 0) {
475 476
 		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 502
 
503 503
 		if (s->flags & AVP_CLASS_URI) {
504 504
 			s->flags &= ~AVP_CLASS_URI;
505
-			s->avp = *select_list(s->flags);
505
+			list = select_list(s->flags);
506 506
 		} else if (s->flags & AVP_CLASS_USER) {
507 507
 			s->flags &= ~AVP_CLASS_USER;
508
-			s->avp = *select_list(s->flags);
508
+			list = select_list(s->flags);
509 509
 		} else if (s->flags & AVP_CLASS_DOMAIN) {
510 510
 			s->flags &= ~AVP_CLASS_DOMAIN;
511
-			s->avp = *select_list(s->flags);
511
+			list = select_list(s->flags);
512 512
 		} else {
513 513
 			s->flags &= ~AVP_CLASS_GLOBAL;
514 514
 			return 0;
515 515
 		}
516
+		if (!list) return 0;
517
+		s->avp = *list;
516 518
 	}
517 519
 
518 520
 	return 0;