Skip to content

Commit

Permalink
chan_simpleusb, chan_usbradio: Check for invalid config. (#292)
Browse files Browse the repository at this point in the history
If the loaded config file is invalid, abort rather than
proceed, to avoid a crash.

Commit de3b94a
(for issue #281) eliminated the separate config
file per node, but we still print the old filenames,
so also update that.

Resolves: #291
  • Loading branch information
InterLinked1 committed Mar 16, 2024
1 parent d9fb08f commit 5c7e553
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions channels/chan_simpleusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,7 @@ static int susb_tune(int fd, int argc, const char *const *argv)
o->txcapraw = 1;
} else if (!strcasecmp(argv[2], "save")) {
tune_write(o);
ast_cli(fd, "Saved radio tuning settings to simpleusb_tune_%s.conf\n", o->name);
ast_cli(fd, "Saved radio tuning settings to simpleusb.conf\n");
} else if (!strcasecmp(argv[2], "load")) {
ast_mutex_lock(&o->eepromlock);
while (o->eepromctl) {
Expand Down Expand Up @@ -3209,7 +3209,7 @@ static void tune_menusupport(int fd, struct chan_simpleusb_pvt *o, const char *c
break;
case 'j': /* save settings */
tune_write(o);
ast_cli(fd, "Saved radio tuning settings to simpleusb_tune_%s.conf\n", o->name);
ast_cli(fd, "Saved radio tuning settings to simpleusb.conf\n");
break;
case 'k': /* change echo mode */
if (cmd[1]) {
Expand Down Expand Up @@ -3642,6 +3642,9 @@ static int load_config(int reload)
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
ast_log(LOG_NOTICE, "Config file %s unchanged, skipping.\n", CONFIG);
return 0;
} else if (cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", CONFIG);
return -1;
}

/* store the configuration */
Expand Down
7 changes: 5 additions & 2 deletions channels/chan_usbradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2972,7 +2972,7 @@ static int radio_tune(int fd, int argc, const char *const *argv)
o->txcapraw = 1;
} else if (!strcasecmp(argv[2], "save")) {
tune_write(o);
ast_cli(fd, "Saved radio tuning settings to usbradio_tune_%s.conf\n", o->name);
ast_cli(fd, "Saved radio tuning settings to usbradio.conf\n");
} else if (!strcasecmp(argv[2], "load")) {
ast_mutex_lock(&o->eepromlock);
while (o->eepromctl) {
Expand Down Expand Up @@ -3880,7 +3880,7 @@ static void tune_menusupport(int fd, struct chan_usbradio_pvt *o, const char *cm
break;
case 'j': /* save tune settings */
tune_write(o);
ast_cli(fd, "Saved radio tuning settings to usbradio_tune_%s.conf\n", o->name);
ast_cli(fd, "Saved radio tuning settings to usbradio.conf\n");
break;
case 'k': /* change echo mode */
if (cmd[1]) {
Expand Down Expand Up @@ -5076,6 +5076,9 @@ static int load_config(int reload)
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
ast_log(LOG_NOTICE, "Config file %s unchanged, skipping.\n", CONFIG);
return 0;
} else if (cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", CONFIG);
return -1;
}

/* store the configuration */
Expand Down

0 comments on commit 5c7e553

Please sign in to comment.