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/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/11168 ) Change subject: vty logging: fix crash when missing 'logging enable' ...................................................................... vty logging: fix crash when missing 'logging enable' We must explicitly check the return value of osmo_log_vty2tgt(), or may run into a segfault. I wasn't aware of this and introduced numerous such cases in I36f17c131cc70ce5a1aef62fd9693097de230cd4. Reproduce: on the VTY, do not issue 'logging enable', invoke 'logging level force-all LEVEL' first. Show in logging_vty_test.vty that this situation is now again amended by telling the user that logging was not enabled. Related: OS#3611 Change-Id: Id11702d1801d6654ca5e5a51b597a0d802e2e8dd --- M src/vty/logging_vty.c M tests/logging/logging_vty_test.vty 2 files changed, 11 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Pau Espin Pedrol: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 31edb52..f3e1419 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -364,6 +364,10 @@ struct log_target *tgt = osmo_log_vty2tgt(vty); int level = log_parse_level(argv[0]); int i; + + if (!tgt) + return CMD_WARNING; + for (i = 0; i < osmo_log_info->num_cat; i++) { struct log_category *cat = &tgt->categories[i]; /* skip empty entries in the array */ @@ -391,6 +395,8 @@ { struct log_target *tgt = osmo_log_vty2tgt(vty); int level = log_parse_level(argv[0]); + if (!tgt) + return CMD_WARNING; log_set_log_level(tgt, level); return CMD_SUCCESS; } @@ -400,6 +406,8 @@ NO_STR LOGGING_STR LEVEL_STR NO_FORCE_ALL_STR) { struct log_target *tgt = osmo_log_vty2tgt(vty); + if (!tgt) + return CMD_WARNING; log_set_log_level(tgt, 0); return CMD_SUCCESS; } diff --git a/tests/logging/logging_vty_test.vty b/tests/logging/logging_vty_test.vty index 0eedbe3..b190927 100644 --- a/tests/logging/logging_vty_test.vty +++ b/tests/logging/logging_vty_test.vty @@ -28,6 +28,9 @@ logging_vty_test(config)# no log stderr logging_vty_test(config)# exit +logging_vty_test# logging level force-all notice +Logging was not enabled. + logging_vty_test# logging enable logging_vty_test# logging filter all 1 logging_vty_test# logging print category-hex 0 -- To view, visit https://gerrit.osmocom.org/11168 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Id11702d1801d6654ca5e5a51b597a0d802e2e8dd Gerrit-Change-Number: 11168 Gerrit-PatchSet: 1 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181001/f1592dab/attachment.htm>