AmendHub

Download:

jcs

/

subtext

/

amendments

/

523

settings+sysop: Fix bug in settings editor that can corrupt settings

When hanging up the connection in the settings struct editor without
giving a response, session_menu returns 0, which we then returned
from struct_editor while setting new_config to NULL. Then we wrote
that NULL dereference as the new db config which trashed it :(
 
When the sesson is ending, make struct_editor return -1 and add an
explicit check in sysop_edit_settings to make sure the new config
isn't NULL.

jcs made amendment 523 about 1 year ago
--- settings.c Fri Jun 16 09:33:35 2023 +++ settings.c Mon Aug 28 09:40:55 2023 @@ -324,6 +324,7 @@ get_input: if (s->ending) { any_changes = false; + ret = -1; goto done; } } --- sysop.c Fri Apr 7 09:38:23 2023 +++ sysop.c Mon Aug 28 11:35:51 2023 @@ -146,7 +146,7 @@ sysop_edit_settings(struct session *s) ret = struct_editor(s, config_fields, nconfig_fields, NULL, 0, &db->config, sizeof(struct config), (void *)&new_config, "BBS Settings", "Sysop:Settings"); - if (ret != 0) { + if (ret != 0 || new_config == NULL) { session_printf(s, "No changes made\r\n"); return; }