Change in openbsc[master]: bsc-nat: ipaccess_auth_bsc: Close bsc conn immediately on bad format ...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Fri Jun 8 11:39:31 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/9510


Change subject: bsc-nat: ipaccess_auth_bsc: Close bsc conn immediately on bad format received
......................................................................

bsc-nat: ipaccess_auth_bsc: Close bsc conn immediately on bad format received

This commit changes behaviour to a (imho) better logic and is a
preparation for follow-up commits to avoid heap-use-after-free error
when closing the bsc connection.

Previously, authentication would still not be accepted but the
connection would be staying alive for a while until id_timeout timer
triggers. Let's close the connection immediately instead, this way BSC
side can see quickly something is wrong with what it is sending.

Furthermore, this way the logic of the function is simplified: If auth
goes well, conn is alive. If auth goes wrong, conn is closed.

Change-Id: I972961b8967076c56c607f98c2360054144951e4
---
M openbsc/src/osmo-bsc_nat/bsc_nat.c
1 file changed, 2 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/10/9510/1

diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 373ba97..fb2ec83 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1038,12 +1038,14 @@
 	if (len <= 0) {
 		LOGP(DNAT, LOGL_ERROR, "Token with length zero on fd: %d\n",
 			bsc->write_queue.bfd.fd);
+		bsc_close_connection(bsc);
 		return;
 	}
 
 	if (token[len - 1] != '\0') {
 		LOGP(DNAT, LOGL_ERROR, "Token not null terminated on fd: %d\n",
 			bsc->write_queue.bfd.fd);
+		bsc_close_connection(bsc);
 		return;
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/9510
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I972961b8967076c56c607f98c2360054144951e4
Gerrit-Change-Number: 9510
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180608/95f29753/attachment.htm>


More information about the gerrit-log mailing list