diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-03-30 07:35:46 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-03-30 07:45:52 +0200 |
commit | 1b17913cbc75fc8fd96b5ffae14ec462e2d7c010 (patch) | |
tree | 17f3dec9b936af67e21147adaf030fcea1a07ac1 /openbsc/src/nat/bsc_nat.c | |
parent | ce2a36840d4341676f7c1767e0f3bc73db76c504 (diff) |
nat: Fail more early in the case of not being authenticated
This is also fixing a possible memory leak.
Diffstat (limited to 'openbsc/src/nat/bsc_nat.c')
-rw-r--r-- | openbsc/src/nat/bsc_nat.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index e6978bfe1..9bd301f78 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -368,10 +368,17 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg) struct bsc_connection *found_bsc = NULL; struct bsc_nat_parsed *parsed; + if (!bsc->authenticated) { + LOGP(DNAT, LOGL_ERROR, "BSC is not authenticated.\n"); + msgb_free(msg); + return -1; + } + /* Parse and filter messages */ parsed = bsc_nat_parse(msg); if (!parsed) { LOGP(DNAT, LOGL_ERROR, "Can not parse msg from BSC.\n"); + msgb_free(msg); return -1; } @@ -411,11 +418,6 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg) goto exit2; } - if (!bsc->authenticated) { - LOGP(DNAT, LOGL_ERROR, "BSC is not authenticated.\n"); - goto exit2; - } - /* send the non-filtered but maybe modified msg */ if (write_queue_enqueue(&msc_con->write_queue, msg) != 0) { LOGP(DNAT, LOGL_ERROR, "Can not queue message for the MSC.\n"); |