mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Fix probable crash
This commit is contained in:
parent
6e0808fef3
commit
05bab1b23d
3 changed files with 33 additions and 2 deletions
4
log.c
4
log.c
|
|
@ -163,6 +163,10 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
char buf[1024];
|
||||
char *description, *separator;
|
||||
|
||||
if (msg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mutex_log);
|
||||
|
||||
if (severity > log_severity) {
|
||||
|
|
|
|||
21
ubus_utils.c
21
ubus_utils.c
|
|
@ -397,16 +397,33 @@ int icwmp_ubus_invoke(const char *obj, const char *method, struct blob_attr *msg
|
|||
{
|
||||
uint32_t id;
|
||||
int rc = 0;
|
||||
int retry = 0;
|
||||
|
||||
struct ubus_context *ubus_ctx = NULL;
|
||||
|
||||
ubus_ctx = ubus_connect(NULL);
|
||||
while (ubus_ctx == NULL && retry < 5) {
|
||||
retry ++;
|
||||
CWMP_LOG(DEBUG, "Failed to connect ubus retry after 1 sec");
|
||||
sleep(1);
|
||||
ubus_ctx = ubus_connect(NULL);
|
||||
}
|
||||
|
||||
if (ubus_ctx == NULL) {
|
||||
CWMP_LOG(ERROR, "Failed to connect with ubus");
|
||||
CWMP_LOG(ERROR, "Failed to connect with ubus err: %d", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ubus_lookup_id(ubus_ctx, obj, &id)) {
|
||||
retry = 0;
|
||||
rc = ubus_lookup_id(ubus_ctx, obj, &id);
|
||||
while (rc != 0 && retry < 5) {
|
||||
retry ++;
|
||||
CWMP_LOG(DEBUG, "Failed to ubus lookup %s, retry after 1 sec", obj);
|
||||
sleep(1);
|
||||
rc = ubus_lookup_id(ubus_ctx, obj, &id);
|
||||
}
|
||||
|
||||
if (!rc) {
|
||||
rc = ubus_invoke(ubus_ctx, id, method, msg, icwmp_callback, callback_arg, 60000);
|
||||
} else {
|
||||
CWMP_LOG(ERROR, "Failed to ubus lookup %s", obj);
|
||||
|
|
|
|||
10
xml.c
10
xml.c
|
|
@ -140,9 +140,19 @@ int xml_send_message(struct cwmp *cwmp, struct session *session, struct rpc *rpc
|
|||
mxml_node_t *b;
|
||||
int compression = global_int_param_read(&cwmp->conf.compression);
|
||||
|
||||
if (session == NULL) {
|
||||
CWMP_LOG(ERROR, "Received session is NULL");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (session->tree_out) {
|
||||
unsigned char *zmsg_out;
|
||||
msg_out = mxmlSaveAllocString(session->tree_out, whitespace_cb);
|
||||
if (msg_out == NULL) {
|
||||
CWMP_LOG(ERROR, "Received tree_out is empty");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CWMP_LOG_XML_MSG(DEBUG, msg_out, XML_MSG_OUT);
|
||||
if (compression != COMP_NONE) {
|
||||
if (zlib_compress(msg_out, &zmsg_out, &msg_out_len, compression)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue