aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/paging.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-12-01 08:47:53 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-12-01 08:47:53 +0100
commit127ec05b4e7c3dfbb17720e583ed71a4fba5d622 (patch)
tree70026b547b1c0e4fe85f32ef96828e5dba28efc9 /src/common/paging.c
parent79da6f3283065d900075bf1610f9eb5098863d74 (diff)
paging: Do not crash if we get called for the wrong frame/t1/t2/t3
If someone wants to have paging for a wrong frame, gracefully return and do not fill the output buffer. Because we are on the wrong frame I think it is best to not fill the frame, this is why I did not add a check to l1_if.c to generate an empty frame.
Diffstat (limited to 'src/common/paging.c')
-rw-r--r--src/common/paging.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/common/paging.c b/src/common/paging.c
index 4d65a046..7197daa9 100644
--- a/src/common/paging.c
+++ b/src/common/paging.c
@@ -295,10 +295,20 @@ static void sort_pr_tmsi_imsi(struct paging_record *pr[], unsigned int n)
/* generate paging message for given gsm time */
int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time *gt)
{
- unsigned int group = get_pag_subch_nr(ps, gt);
- struct llist_head *group_q = &ps->paging_queue[group];
+ struct llist_head *group_q;
+ int group;
int len;
+ group = get_pag_subch_nr(ps, gt);
+ if (group < 0) {
+ LOGP(DPAG, LOGL_ERROR,
+ "Paging called for GSM wrong time: FN %d/%d/%d/%d.\n",
+ gt->fn, gt->t1, gt->t2, gt->t3);
+ return -1;
+ }
+
+ group_q = &ps->paging_queue[group];
+
/* There is nobody to be paged, send Type1 with two empty ID */
if (llist_empty(group_q)) {
//DEBUGP(DPAG, "Tx PAGING TYPE 1 (empty)\n");