mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-09 23:34:38 +01:00
libbbfdm-ubus: fix crash on large Get output
This commit is contained in:
parent
adfdb54d62
commit
880a7583ca
4 changed files with 12 additions and 12 deletions
|
|
@ -367,13 +367,13 @@ int bbfdm_set_handler(struct ubus_context *ctx, struct ubus_object *obj,
|
||||||
fault = fill_pvlist_set(path, value, type, tb[DM_SET_OBJ_PATH], &pv_list);
|
fault = fill_pvlist_set(path, value, type, tb[DM_SET_OBJ_PATH], &pv_list);
|
||||||
if (fault) {
|
if (fault) {
|
||||||
BBF_ERR("Fault in fill pvlist set path |%s| : |%d|", data.bbf_ctx.in_param, fault);
|
BBF_ERR("Fault in fill pvlist set path |%s| : |%d|", data.bbf_ctx.in_param, fault);
|
||||||
fill_err_code_array(&data, fault);
|
fill_err_code_array(&data, &data.bb, fault);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_empty(&pv_list)) {
|
if (list_empty(&pv_list)) {
|
||||||
BBF_ERR("Fault in fill pvlist set path |%s| : |list is empty|", data.bbf_ctx.in_param);
|
BBF_ERR("Fault in fill pvlist set path |%s| : |list is empty|", data.bbf_ctx.in_param);
|
||||||
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR);
|
fill_err_code_array(&data, &data.bb, USP_FAULT_INTERNAL_ERROR);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ bool validate_msglen(bbfdm_data_t *data)
|
||||||
BBF_ERR("Blob exceed max len(%d), data len(%zd)", DEF_IPC_DATA_LEN, data_len);
|
BBF_ERR("Blob exceed max len(%d), data len(%zd)", DEF_IPC_DATA_LEN, data_len);
|
||||||
blob_buf_free(&data->bbf_ctx.bb);
|
blob_buf_free(&data->bbf_ctx.bb);
|
||||||
blob_buf_init(&data->bbf_ctx.bb, 0);
|
blob_buf_init(&data->bbf_ctx.bb, 0);
|
||||||
fill_err_code_table(data, FAULT_9002);
|
fill_err_code_array(data, &data->bbf_ctx.bb, FAULT_9002);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,13 +167,13 @@ void fill_err_code_table(bbfdm_data_t *data, int fault)
|
||||||
blobmsg_close_table(&data->bb, table);
|
blobmsg_close_table(&data->bb, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_err_code_array(bbfdm_data_t *data, int fault)
|
void fill_err_code_array(bbfdm_data_t *data, struct blob_buf *bb, int fault)
|
||||||
{
|
{
|
||||||
void *array = blobmsg_open_array(&data->bb, "results");
|
void *array = blobmsg_open_array(bb, "results");
|
||||||
void *table = blobmsg_open_table(&data->bb, NULL);
|
void *table = blobmsg_open_table(bb, NULL);
|
||||||
bb_add_string(&data->bb, "path", data->bbf_ctx.in_param);
|
bb_add_string(bb, "path", data->bbf_ctx.in_param);
|
||||||
blobmsg_add_u32(&data->bb, "fault", bbf_fault_map(&data->bbf_ctx, fault));
|
blobmsg_add_u32(bb, "fault", bbf_fault_map(&data->bbf_ctx, fault));
|
||||||
bb_add_string(&data->bb, "fault_msg", data->bbf_ctx.fault_msg);
|
bb_add_string(bb, "fault_msg", data->bbf_ctx.fault_msg);
|
||||||
blobmsg_close_table(&data->bb, table);
|
blobmsg_close_table(bb, table);
|
||||||
blobmsg_close_array(&data->bb, array);
|
blobmsg_close_array(bb, array);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ void add_path_list(const char *param, struct list_head *plist);
|
||||||
void free_path_list(struct list_head *plist);
|
void free_path_list(struct list_head *plist);
|
||||||
|
|
||||||
void fill_err_code_table(bbfdm_data_t *data, int fault);
|
void fill_err_code_table(bbfdm_data_t *data, int fault);
|
||||||
void fill_err_code_array(bbfdm_data_t *data, int fault);
|
void fill_err_code_array(bbfdm_data_t *data, struct blob_buf *bb, int fault);
|
||||||
|
|
||||||
void bb_add_string(struct blob_buf *bb, const char *name, const char *value);
|
void bb_add_string(struct blob_buf *bb, const char *name, const char *value);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue