#include "mdns.h"
#include "mdns_private.h"
#include "mdns_networking.h"
+#include "esp_log.h"
#include <string.h>
#ifdef MDNS_ENABLE_DEBUG
mdns_server_t * _mdns_server = NULL;
+static const char *TAG = "MDNS";
+
static volatile TaskHandle_t _mdns_service_task_handle = NULL;
static SemaphoreHandle_t _mdns_service_semaphore = NULL;
//need to add -2 to string
ret = malloc(strlen(in) + 3);
if (ret == NULL) {
+ HOOK_MALLOC_FAILED;
return NULL;
}
sprintf(ret, "%s-2", in);
} else {
ret = malloc(strlen(in) + 2); //one extra byte in case 9-10 or 99-100 etc
+ if (ret == NULL) {
+ HOOK_MALLOC_FAILED;
+ return NULL;
+ }
strcpy(ret, in);
int baseLen = p - in; //length of 'bla' in 'bla-123'
//overwrite suffix with new suffix
action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
return 0;
}
data_len += l;
+ } else {
+ HOOK_MALLOC_FAILED;
+ // continue
}
txt = txt->next;
}
mdns_out_answer_t * a = (mdns_out_answer_t *)malloc(sizeof(mdns_out_answer_t));
if (!a) {
+ HOOK_MALLOC_FAILED;
return false;
}
a->type = type;
{
mdns_tx_packet_t * packet = (mdns_tx_packet_t*)malloc(sizeof(mdns_tx_packet_t));
if (!packet) {
+ HOOK_MALLOC_FAILED;
return NULL;
}
memset((uint8_t*)packet, 0, sizeof(mdns_tx_packet_t));
for (i=0; i<len; i++) {
mdns_out_question_t * q = (mdns_out_question_t *)malloc(sizeof(mdns_out_question_t));
if (!q) {
+ HOOK_MALLOC_FAILED;
_mdns_free_tx_packet(packet);
return NULL;
}
if (include_ip && !_str_null_or_empty(_mdns_server->hostname)) {
mdns_out_question_t * q = (mdns_out_question_t *)malloc(sizeof(mdns_out_question_t));
if (!q) {
+ HOOK_MALLOC_FAILED;
_mdns_free_tx_packet(packet);
return NULL;
}
if (services_final_len) {
_services = (mdns_srv_item_t **)malloc(sizeof(mdns_srv_item_t *) * services_final_len);
if (!_services) {
+ HOOK_MALLOC_FAILED;
return;
}
for (i=0; i<num_items; i++) {
mdns_txt_linked_item_t * new_item = (mdns_txt_linked_item_t *)malloc(sizeof(mdns_txt_linked_item_t));
if (!new_item) {
+ HOOK_MALLOC_FAILED;
break;
}
new_item->key = strdup(txt[i].key);
{
mdns_service_t * s = (mdns_service_t *)malloc(sizeof(mdns_service_t));
if (!s) {
+ HOOK_MALLOC_FAILED;
return NULL;
}
sprintf(tmp, "%s=%s", txt->key, txt->value);
_mdns_append_string(ours, &index, tmp);
free(tmp);
+ } else {
+ HOOK_MALLOC_FAILED;
+ // continue
}
txt = txt->next;
}
}
mdns_txt_item_t * txt = (mdns_txt_item_t *)malloc(sizeof(mdns_txt_item_t) * num_items);
+ if (!txt) {
+ HOOK_MALLOC_FAILED;
+ return;
+ }
memset(txt, 0, sizeof(mdns_txt_item_t) * num_items);
size_t txt_num = 0;
}
char * key = (char *)malloc(name_len + 1);
if (!key) {
+ HOOK_MALLOC_FAILED;
goto handle_error;//error
}
int value_len = partLen - name_len - 1;
if (value_len > 0) {
char * value = (char *)malloc(value_len + 1);
+ if (!value) {
+ HOOK_MALLOC_FAILED;
+ goto handle_error;//error
+ }
memcpy(value, data + i, value_len);
value[value_len] = 0;
i += value_len;
mdns_parsed_packet_t * parsed_packet = (mdns_parsed_packet_t *)malloc(sizeof(mdns_parsed_packet_t));
if (!parsed_packet) {
+ HOOK_MALLOC_FAILED;
return;
}
memset(parsed_packet, 0, sizeof(mdns_parsed_packet_t));
while (a) {
mdns_parsed_question_t * question = (mdns_parsed_question_t *)malloc(sizeof(mdns_parsed_question_t));
if (!question) {
+ HOOK_MALLOC_FAILED;
goto clear_rx_packet;
}
question->next = parsed_packet->questions;
mdns_parsed_question_t * question = (mdns_parsed_question_t *)malloc(sizeof(mdns_parsed_question_t));
if (!question) {
+ HOOK_MALLOC_FAILED;
goto clear_rx_packet;
}
question->next = parsed_packet->questions;
{
mdns_search_once_t * search = (mdns_search_once_t *)malloc(sizeof(mdns_search_once_t));
if (!search) {
+ HOOK_MALLOC_FAILED;
return NULL;
}
memset(search, 0, sizeof(mdns_search_once_t));
{
mdns_ip_addr_t * a = (mdns_ip_addr_t *)malloc(sizeof(mdns_ip_addr_t));
if (!a) {
+ HOOK_MALLOC_FAILED;
return NULL;
}
memset(a, 0 , sizeof(mdns_ip_addr_t));
if (!search->max_results || search->num_results < search->max_results) {
r = (mdns_result_t *)malloc(sizeof(mdns_result_t));
if (!r) {
+ HOOK_MALLOC_FAILED;
return;
}
if (!search->max_results || search->num_results < search->max_results) {
r = (mdns_result_t *)malloc(sizeof(mdns_result_t));
if (!r) {
+ HOOK_MALLOC_FAILED;
return NULL;
}
if (!search->max_results || search->num_results < search->max_results) {
r = (mdns_result_t *)malloc(sizeof(mdns_result_t));
if (!r) {
+ HOOK_MALLOC_FAILED;
return;
}
if (!search->max_results || search->num_results < search->max_results) {
r = (mdns_result_t *)malloc(sizeof(mdns_result_t));
if (!r) {
+ HOOK_MALLOC_FAILED;
goto free_txt;
}
mdns_out_question_t * q = (mdns_out_question_t *)malloc(sizeof(mdns_out_question_t));
if (!q) {
+ HOOK_MALLOC_FAILED;
_mdns_free_tx_packet(packet);
return NULL;
}
}
mdns_out_answer_t * a = (mdns_out_answer_t *)malloc(sizeof(mdns_out_answer_t));
if (!a) {
+ HOOK_MALLOC_FAILED;
_mdns_free_tx_packet(packet);
return NULL;
}
if (!txt) {
txt = (mdns_txt_linked_item_t *)malloc(sizeof(mdns_txt_linked_item_t));
if (!txt) {
+ HOOK_MALLOC_FAILED;
_mdns_free_action(action);
return;
}
action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
free(action);
_mdns_server->tx_queue_head = p;
}
+ } else {
+ HOOK_MALLOC_FAILED;
+ // continue
}
}
MDNS_SERVICE_UNLOCK();
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_OK;
}
action->type = ACTION_SYSTEM_EVENT;
_mdns_server = (mdns_server_t *)malloc(sizeof(mdns_server_t));
if (!_mdns_server) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
memset((uint8_t*)_mdns_server, 0, sizeof(mdns_server_t));
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
free(new_hostname);
return ESP_ERR_NO_MEM;
}
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
free(new_instance);
return ESP_ERR_NO_MEM;
}
item = (mdns_srv_item_t *)malloc(sizeof(mdns_srv_item_t));
if (!item) {
+ HOOK_MALLOC_FAILED;
_mdns_free_service(s);
return ESP_ERR_NO_MEM;
}
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
_mdns_free_service(s);
free(item);
return ESP_ERR_NO_MEM;
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
action->type = ACTION_SERVICE_PORT_SET;
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
_mdns_free_linked_txt(new_txt);
return ESP_ERR_NO_MEM;
}
}
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
}
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
free(new_instance);
return ESP_ERR_NO_MEM;
}
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
action->type = ACTION_SERVICE_DEL;
mdns_action_t * action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
+ HOOK_MALLOC_FAILED;
return ESP_ERR_NO_MEM;
}
action->type = ACTION_SERVICES_CLEAR;