- Leak of memory or pointers to system resources.
- A pointer to freed memory is dereferenced.
Change-Id: I269d33327e3534ecb14a019c9acfa12c19528b97
Signed-off-by: wansuyoo <wansu.yoo@samsung.com>
printf("<<Client>> __client_open_connection\n");
ret = IPC_OpenClientConnection(server, phndl);
if (0 == ret) {
- printf("<<Client>> phndl->server_h = %d\n", phndl->server_h);
printf("<<Client>> phndl->client_h = %d\n", phndl->client_h);
} else {
printf("<<Client>> connection_init ERROR(%d) !!! {%s}\n", ret, SERVER);
int __create_system_config_file(struct json_object *jsonObj, char *write_file)
{
- int ret = 0;
+ int ret = 0, rv = 0;
if (jsonObj) {
struct json_object *jsonObjVer = NULL; // extract version object
// prepare json objects
- json_object_object_get_ex(jsonObj, "version", &jsonObjVer);
- json_object_object_del(jsonObj, "wifi");
- json_object_object_del(jsonObj, "ethernet");
+ if (json_object_object_get_ex(jsonObj, "version", &jsonObjVer)) {
+ json_object_object_del(jsonObj, "wifi");
+ json_object_object_del(jsonObj, "ethernet");
- json_object_to_file_ext(write_file, jsonObj, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
+ rv = json_object_to_file_ext(write_file, jsonObj, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
+ if (rv < 0)
+ ret = -1;
+ } else {
+ ret = -1;
+ }
} else {
ret = -1;
}
int __create_target_config_file(struct json_object *jsonObj, char *write_file)
{
- int ret = 0;
+ int ret = 0, rv = 0;
if (jsonObj) {
struct json_object *jsonObjVer = NULL; // extract version object
struct json_object *jsonObjName = NULL; // extract deviceName object
// prepare json objects
- json_object_object_get_ex(jsonObj, "version", &jsonObjVer);
- json_object_object_get_ex(jsonObj, "deviceName", &jsonObjName);
+ if (json_object_object_get_ex(jsonObj, "version", &jsonObjVer)) {
+ if (json_object_object_get_ex(jsonObj, "deviceName", &jsonObjName)) {
- // result string for target
- struct json_object *jsonObjResultTarget = json_object_new_object();
- json_object_object_add(jsonObjResultTarget, "version", jsonObjVer);
- if (jsonObjName)
- json_object_object_add(jsonObjResultTarget, "deviceName", jsonObjName);
+ // result string for target
+ struct json_object *jsonObjResultTarget = json_object_new_object();
+ json_object_object_add(jsonObjResultTarget, "version", jsonObjVer);
+ if (jsonObjName)
+ json_object_object_add(jsonObjResultTarget, "deviceName", jsonObjName);
- json_object_to_file_ext(write_file, jsonObjResultTarget, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
+ rv = json_object_to_file_ext(write_file, jsonObjResultTarget, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
+ if (rv < 0)
+ ret = -1;
+ } else {
+ ret = -1;
+ }
+ } else {
+ ret = -1;
+ }
} else {
ret = -1;
}
fd = open(ENVIRONMENT_PROXY_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd > 0) {
write(fd, writeBuff, strlen(writeBuff));
- close(fd);
} else {
ret = SA_ERROR_NOT_AVAILABLE;
_E("Cannot open file");
}
+ close(fd);
}
return ret;
fd = creat(CONFIG_DOCKERD_DAEMON_FILE, 0644);
if (fd > 0) {
write(fd, buf, strlen(buf));
- close(fd);
} else {
ret = SA_ERROR_NOT_AVAILABLE;
_E("Cannot create file");
}
+ close(fd);
if (buf != NULL)
free(buf);
if (dir_info != NULL) {
while (dir_entry = readdir(dir_info)) {
if (__get_file_extension(dir_entry->d_name, &fileExt) == 0) {
- if (strncmp(fileExt, "crt", 3) == 0) {
- snprintf(file_name, sizeof(file_name), "%s%s", USER_CERT_DIR_PATH, dir_entry->d_name);
- if (__search_str_pattern(SYSTEM_CERT_FILE, file_name) != 0) { // un-matched file, need to be applied
- if (__apply_ca_cert_file(file_name) != 0)
- _D("File[%s]: apply error!!!", dir_entry->d_name);
- else
- _D("File[%s]: applied successfully ca-certificate!!!", dir_entry->d_name);
- } else
- _D("FILE[%s]: already applied!!!", dir_entry->d_name);
+ if (fileExt != NULL) {
+ if (strncmp(fileExt, "crt", 3) == 0) {
+ snprintf(file_name, sizeof(file_name), "%s%s", USER_CERT_DIR_PATH, dir_entry->d_name);
+ if (__search_str_pattern(SYSTEM_CERT_FILE, file_name) != 0) { // un-matched file, need to be applied
+ if (__apply_ca_cert_file(file_name) != 0)
+ _D("File[%s]: apply error!!!", dir_entry->d_name);
+ else
+ _D("File[%s]: applied successfully ca-certificate!!!", dir_entry->d_name);
+ } else {
+ _D("FILE[%s]: already applied!!!", dir_entry->d_name);
+ }
+ }
+ free(fileExt);
+ fileExt = NULL;
}
- free(fileExt);
} else
_D("File[%s]: Not valid certificate file", dir_entry->d_name);
}
_D("platformVer[%s]", os_info_h->platformVer);
free(ret_buf);
+ ret_buf = NULL;
}
// get base OS version
ret = CLI_command(GET_BASEOS_VERSION_CMD, 1, &ret_buf);
_D("baseOSVer[%s]", os_info_h->baseOSVer);
free(ret_buf);
+ ret_buf = NULL;
}
// get docker version
ret = CLI_command(GET_DOCKER_VERSION_CMD, 1, &ret_buf);
_D("dockerVer[%s]", os_info_h->dockerVer);
free(ret_buf);
+ ret_buf = NULL;
}
}