buffer = (char *) malloc(EVENT_BUF_LEN);
if (buffer != NULL) {
+ memset(buffer, 0x00, EVENT_BUF_LEN);
// Start callack
_D("Registerd Callback Triggered");
callback(SA_FILE_STATE_REGISTERED, NULL, NULL);
_D("__parse_network_static_info input error");
return -1;
}
+
+ memset(staticInfo, 0x00, sizeof(sa_network_static_s));
//ipAddress
ipAddress = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_IPADDRESS);
if (ipAddress != NULL) {
_D("__parse_network_eth input error");
return -1;
}
+
+ memset(eth, 0x00, sizeof(sa_eth_s));
// enabled
eth->enabled = json_get_boolean_from_obj(inputObj, SA_CONFIG_NETWORKDATA_ENABLED);
_D("__parse_network_wifi input error");
return -1;
}
+
+ memset(wifi, 0x00, sizeof(sa_wifi_s));
// enabled
wifi->enabled = json_get_boolean_from_obj(inputObj, SA_CONFIG_NETWORKDATA_ENABLED);
setupConfig->networkData = (sa_network_s *) malloc(sizeof(sa_network_s));
if (setupConfig->networkData != NULL) {
+ memset(setupConfig->networkData, 0x00, sizeof(sa_network_s));
//parse wifi
if (json_object_object_get_ex(inputObj, SA_CONFIG_NETWORKDATA_WIFI, &wifiObj)) {
if (json_object_get_type(wifiObj) == json_type_object) {
return -1;
}
+ memset(opt, 0x00, sizeof(sa_dockerd_opt_s));
+
opt->count = json_object_array_length(inputObj);
if (opt->count > 0) {
opt->insecureRegistries = (char **) malloc(sizeof(char *) * opt->count);
ret = -1;
_E("malloc failed for inscureRegistries first");
}
+ } else {
+ _D("Insecure registries is empty");
}
return ret;
setupConfig->systemData = (sa_system_s *) malloc(sizeof(sa_system_s));
if (setupConfig->systemData != NULL) {
+ memset(setupConfig->systemData, 0x00, sizeof(sa_system_s));
//httpProxy
httpProxy = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_HTTPPROXY);
if (httpProxy != NULL) {
- setupConfig->systemData->proxy = (sa_proxy_s *) malloc(sizeof(sa_proxy_s));
- if (setupConfig->systemData->proxy != NULL) {
- memcpy(setupConfig->systemData->proxy->httpProxy, httpProxy, MIN(strlen(httpProxy), sizeof(setupConfig->systemData->proxy->httpProxy) - 1));
- } else {
- ret = -1;
- _D("malloc fail setupConfig->systemData->proxy");
+ if (strlen(httpProxy) > 0) {
+ setupConfig->systemData->proxy = (sa_proxy_s *) malloc(sizeof(sa_proxy_s));
+ if (setupConfig->systemData->proxy != NULL) {
+ memcpy(setupConfig->systemData->proxy->httpProxy, httpProxy, MIN(strlen(httpProxy), sizeof(setupConfig->systemData->proxy->httpProxy) - 1));
+ } else {
+ ret = -1;
+ _D("malloc fail setupConfig->systemData->proxy");
+ }
}
}
if (json_object_object_get_ex(inputObj, SA_CONFIG_SYSTEMDATA_INSECURE_REGISTRIES, &arrayObj)) {
if (json_object_get_type(arrayObj) == json_type_array) {
setupConfig->systemData->dockerdOpt = (sa_dockerd_opt_s *) malloc(sizeof(sa_dockerd_opt_s));
- if (setupConfig->systemData->dockerdOpt != NULL)
+ if (setupConfig->systemData->dockerdOpt != NULL) {
ret = __parse_system_insecure_registries(arrayObj, setupConfig->systemData->dockerdOpt);
- else {
+ } else {
_E("malloc failed setupConfig->systemData->dockerdOpt");
ret = -1;
}
registryObj = json_object_new_object();
arrayObj = json_object_new_array();
- if (registryObj != NULL && arrayObj != NULL) {
- if (opt->count > 0) {
+ if (opt->count > 0) {
+ if (registryObj != NULL && arrayObj != NULL) {
for (ulIndex = 0; ulIndex < opt->count; ulIndex++) {
// string add in arrayObj
/*Creating json strings*/
}
}
json_object_object_add(registryObj, SA_CONFIG_SYSTEMDATA_INSECURE_REGISTRIES, arrayObj);
- }
- buf = json_object_to_json_string_ext(registryObj, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
+ buf = json_object_to_json_string_ext(registryObj, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
- if (buf != NULL) {
- *value = (char *)malloc(strlen(buf)+1);
- if (*value != NULL) {
- buf_len = strlen(buf);
- memset(*value, 0x00, strlen(buf)+1);
- memcpy(*value, buf, strlen(buf) + 1);
- _D("service create json:[%s]", *value);
+ if (buf != NULL) {
+ *value = (char *)malloc(strlen(buf)+1);
+ if (*value != NULL) {
+ buf_len = strlen(buf);
+ memset(*value, 0x00, strlen(buf)+1);
+ memcpy(*value, buf, strlen(buf) + 1);
+ _D("service create json:[%s]", *value);
+ }
}
- }
- } else
- _D("empty object is not created");
+ } else
+ _D("empty object is not created");
+ }
+
if (registryObj != NULL)
json_object_put(registryObj);