fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/31945 )


Change subject: layer23/{mobile,modem}: fix segfault on VTY connection
......................................................................

layer23/{mobile,modem}: fix segfault on VTY connection

It was a mistake to call vty_init(), passing it a pointer to the
vty_app_info structure allocated on the stack, because it gets
overwritten when the calling function _vty_init() returns.

Change-Id: I75843a964254243c70bedcf8ff97d854107ee21a
Fixes: 9feb5057 "layer23: refactor the application API concept"
---
M src/host/layer23/include/osmocom/bb/common/l23_app.h
M src/host/layer23/src/common/main.c
M src/host/layer23/src/mobile/app_mobile.c
M src/host/layer23/src/mobile/main.c
M src/host/layer23/src/modem/app_modem.c
5 files changed, 21 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/45/31945/1

diff --git a/src/host/layer23/include/osmocom/bb/common/l23_app.h 
b/src/host/layer23/include/osmocom/bb/common/l23_app.h
index fd8c877..6cf0b7e 100644
--- a/src/host/layer23/include/osmocom/bb/common/l23_app.h
+++ b/src/host/layer23/include/osmocom/bb/common/l23_app.h
@@ -60,7 +60,7 @@
 struct l23_app_info {
        const char *copyright;
        const char *contribution;
-       const struct vty_app_info *vty_info; /* L23_OPT_VTY */
+       struct vty_app_info *vty_info; /* L23_OPT_VTY */

        char *getopt_string;
        uint32_t opt_supported; /* mask of L23_OPT_* */
diff --git a/src/host/layer23/src/common/main.c 
b/src/host/layer23/src/common/main.c
index e4a15ee..567b2e0 100644
--- a/src/host/layer23/src/common/main.c
+++ b/src/host/layer23/src/common/main.c
@@ -203,14 +203,12 @@

 static int _vty_init(void)
 {
-       struct vty_app_info info;
        int rc;

        OSMO_ASSERT(l23_app_info.vty_info != NULL);
-       info = *l23_app_info.vty_info;
-       info.tall_ctx = l23_ctx;
+       l23_app_info.vty_info->tall_ctx = l23_ctx;

-       vty_init(&info);
+       vty_init(l23_app_info.vty_info);
        logging_vty_add_cmds();

        if (l23_app_info.vty_init != NULL)
diff --git a/src/host/layer23/src/mobile/app_mobile.c 
b/src/host/layer23/src/mobile/app_mobile.c
index a3b36e3..a61774b 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -490,7 +490,7 @@
        return ms_vty_init();
 }

-static const struct vty_app_info _mobile_vty_info = {
+static struct vty_app_info _mobile_vty_info = {
        .name = "mobile",
        .version = PACKAGE_VERSION,
 };
diff --git a/src/host/layer23/src/mobile/main.c 
b/src/host/layer23/src/mobile/main.c
index d24a802..eca082a 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -217,14 +217,12 @@

 static int _vty_init(void)
 {
-       struct vty_app_info info;
        int rc;

        OSMO_ASSERT(l23_app_info.vty_info != NULL);
-       info = *l23_app_info.vty_info;
-       info.tall_ctx = l23_ctx;
+       l23_app_info.vty_info->tall_ctx = l23_ctx;

-       vty_init(&info);
+       vty_init(l23_app_info.vty_info);
        logging_vty_add_cmds();

        if (l23_app_info.vty_init != NULL)
diff --git a/src/host/layer23/src/modem/app_modem.c 
b/src/host/layer23/src/modem/app_modem.c
index 58328c2..d9d40cd 100644
--- a/src/host/layer23/src/modem/app_modem.c
+++ b/src/host/layer23/src/modem/app_modem.c
@@ -185,7 +185,7 @@
        return 0;
 }

-static const struct vty_app_info _modem_vty_info = {
+static struct vty_app_info _modem_vty_info = {
        .name = "modem",
        .version = PACKAGE_VERSION,
        .go_parent_cb = modem_vty_go_parent,

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I75843a964254243c70bedcf8ff97d854107ee21a
Gerrit-Change-Number: 31945
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to