From 75889f7bc5058da17100f6d87812a876aeee3273 Mon Sep 17 00:00:00 2001 From: vdutta Date: Wed, 16 Jun 2021 21:27:28 +0530 Subject: [PATCH] Fix garbage characters in info of reload command --- ubus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ubus.c b/ubus.c index 5d6a865..e862613 100755 --- a/ubus.c +++ b/ubus.c @@ -63,7 +63,7 @@ static int cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj blob_buf_init(&b, 0); char *cmd = blobmsg_data(tb[COMMAND_NAME]); - char info[128]; + char info[128] = {0}; if (!strcmp("reload_end_session", cmd)) { CWMP_LOG(INFO, "triggered ubus reload_end_session"); @@ -76,7 +76,8 @@ static int cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj if (cwmp_main.session_status.last_status == SESSION_RUNNING) { cwmp_set_end_session(END_SESSION_RELOAD); blobmsg_add_u32(&b, "status", 0); - blobmsg_add_string(&b, "info", "Session running, reload at the end of the session"); + if (snprintf(info, sizeof(info), "Session running, reload at the end of the session") == -1) + return -1; } else { pthread_mutex_lock(&(cwmp_main.mutex_session_queue)); cwmp_apply_acs_changes();