ubus: fix blob_buf initialization
authorRafał Miłecki <rafal@milecki.pl>
Mon, 14 Sep 2020 14:04:13 +0000 (16:04 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Tue, 15 Sep 2020 11:22:32 +0000 (13:22 +0200)
commitfe1888f19e7f8ee4237409b8616c82926190c2f8
treef76c8bcdfa16d4351f77145cc5215426425a942f
parent212f8364d49c1bc27dd8bdc394fc3615ea9b7ba3
ubus: fix blob_buf initialization

Initializing buffer in the uh_ubus_handle_request() didn't handle
batched requests correctly. It resulted in reusing buffer and generating
malformed replies.

Call blob_buf_init() before every usage of the global buf variable.

While at it make two functions take blob_buf pointer as argument:
1. uh_ubus_send_response()
2. uh_ubus_init_json_rpc_response()

This helps following global "buf" variable usage and will help avoiding
similar bugs in the future.

Fixes: 628341fae412 ("ubus: use local "blob_buf" in uh_ubus_handle_request_object()")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
ubus.c