--------------------------------------------------------------------------------------------
| CID | Type | File | Function |
|------------------------------------------------------------------------------------------|
| 451239 | Uninitialized scalar variable | da_inst.c | ld_add_probes_by_feature |
|------------------------------------------------------------------------------------------|
| 451189 | Resource leak | FileElf.cpp | makeRelocMap |
|------------------------------------------------------------------------------------------|
| 451185 | Resource leak | FileElf.cpp | makeRelocMap |
|------------------------------------------------------------------------------------------|
| 451183 | Resource leak | FileElf.cpp | getAddrPlt |
|------------------------------------------------------------------------------------------|
| 451178 | Resource leak | FileElf.cpp | readSectionsInfo |
|------------------------------------------------------------------------------------------|
| 451172 | Resource leak | da_protocol_inst.c | parse_app_inst_list |
|------------------------------------------------------------------------------------------|
| 451168 | Resource leak | da_protocol_inst.c | add_preload_probes |
|------------------------------------------------------------------------------------------|
| 451167 | Resource leak | da_protocol_inst.c | add_preload_probes |
|------------------------------------------------------------------------------------------|
| 451125 | Null pointer dereferences | wsi.c | wsi_set_smack_rules |
|------------------------------------------------------------------------------------------|
| 451123 | Null pointer dereferences | da_protocol_inst.c | feature_add_func_inst_list |
|------------------------------------------------------------------------------------------|
| 451122 | Null pointer dereferences | wsi.c | send_request |
|------------------------------------------------------------------------------------------|
| 451121 | Null pointer dereferences | da_protocol_inst.c | feature_add_func_inst_list |
|------------------------------------------------------------------------------------------|
| 451076 | Deleting void pointer | FileElf.cpp | putSection |
--------------------------------------------------------------------------------------------
Change-Id: If21d9b2983b3c97d6fa94761f49334f975c94b1b
Signed-off-by: Konstantin Baladurin <k.baladurin@partner.samsung.com>
return 0;
data->size = shdr->sh_size;
- data->data = new char[data->size];
+ data->data = ::operator new(data->size);
if (data->data == 0) {
delete data;
return 0;
void FileElf::putSection(const Data *data)
{
- delete []data->data;
+ ::operator delete(data->data);
delete data;
}
const char *strData = reinterpret_cast<const char *>(data->data);
const char *strDataEnd = strData + data->size;
- if (strData == 0)
- return -ENOMEM;
+ if (strData == 0) {
+ ret = -ENOMEM;
+ goto putSect;
+ }
for (int i = 0; i < _fhdr.e_shnum; ++i) {
Elf32_Shdr shdr;
if (dataRel->size % sizeof(Elf32_Rel)) {
LOGE("'%s' section incorrect\n", nameRel);
- return -EINVAL;
+ ret = -EINVAL;
+ goto putSectRel;
}
rel = reinterpret_cast<Elf32_Rel *>(dataRel->data);
relCnt = dataRel->size / sizeof(Elf32_Rel);
if (dataSym->size % sizeof(Elf32_Sym)) {
LOGE("'%s' section incorrect\n", nameSym);
ret = -EINVAL;
- goto putSectRel;
+ goto putSectSym;
}
sym = reinterpret_cast<Elf32_Sym *>(dataSym->data);
symCnt = dataSym->size / sizeof(Elf32_Sym);
addrs[i] = it == funcMap.end() ? 0 : it->second;
}
+ putSection(data);
return 0;
}
return NULL;
}
+void free_app(struct app_list_t *app)
+{
+ free_app_info(app->app);
+ app->app = NULL;
+ free_data((struct data_list_t *)app);
+}
+
+void free_app_info(struct app_info_t *app_info)
+{
+ free(app_info->app_id);
+ free(app_info->exe_path);
+ free(app_info);
+}
+
struct probe_list_t *new_probe(void)
{
struct probe_list_t *probe;
struct msg_t **msg_reply_add,
struct msg_t **msg_reply_remove)
{
- int i, res;
+ int i, res = 0;
char *p;
struct feature_list_t f;
char buf[1024] = "";
int probe_list_append(struct data_list_t *to, struct probe_list_t *from);
int data_list_append(struct data_list_t **to, struct data_list_t *from);
void free_data_list(struct data_list_t **data);
+void free_app(struct app_list_t *app);
struct app_info_t *app_info_get_first(struct app_list_t **app_list);
struct app_info_t *app_info_get_next(struct app_list_t **app_list);
info->setup_data.data, info->setup_data.size);
if (err) {
LOGE("add app, ret=%d\n", err);
+ free_app(app);
return 0;
}
for (i = 0; i < num; i++) {
parse_deb("app_int #%d\n", i);
probe_el = new_probe();
+
+ if (probe_el == NULL) {
+ LOGE("probe alloc error\n");
+ return 0;
+ }
+
func = malloc(sizeof(struct ld_preload_probe_t));
+ if (func == NULL) {
+ LOGE("func alloc error\n");
+ free(probe_el);
+ return 0;
+ }
+
func->orig_addr = ld_lib.probes[i].orig_addr;
func->probe_type = SWAP_LD_PROBE;
func->handler_addr = ld_lib.probes[i].handler_addr;
if (preload_lib == NULL) {
LOGE("preload lib alloc error\n");
- return 0;
+ ret = 0;
+ goto free_caller_probe;
}
if (get_caller_probe == NULL || get_call_type_probe == NULL) {
LOGE("probe alloc error\n");
- return 0;
+ ret = 0;
+ goto free_caller_probe;
}
preload_lib->lib->bin_path = probe_lib;
/* Add get_caller probe */
ret = create_preload_probe_func(&get_caller_probe, get_caller_addr, 4);
if (ret != 0)
- return ret;
+ goto free_caller_probe;
+
probe_list_append(preload_lib, get_caller_probe);
/* Add get_call_type probe */
ret = create_preload_probe_func(&get_call_type_probe, get_call_type_addr, 5);
if (ret != 0)
- return ret;
+ goto free_call_type_probe;
+
probe_list_append(preload_lib, get_call_type_probe);
preload_lib->func_num = 2;
data_list_append((struct data_list_t **)lib_list, (struct data_list_t *)preload_lib);
return 1;
+
+free_caller_probe:
+ free(get_caller_probe);
+free_call_type_probe:
+ free(get_call_type_probe);
+
+ return ret;
}
size_t id_maxlen = 128;
app_id = malloc(sizeof(char) * (strnlen(app_info->app_id, id_maxlen) + 1));
+
+ if (app_id == NULL) {
+ LOGE("app id alloc error\n");
+ ret = 1;
+ goto exit;
+ }
+
strcpy(app_id, app_info->app_id);
package_id = strtok(app_id, delim);
}
free(app_id);
-
+exit:
return ret;
}
{
#define MAX_REQUEST_LENGTH 128
- json_object *jobj = json_object_new_object();
+ json_object *jobj = NULL;
char buf[LWS_SEND_BUFFER_PRE_PADDING + MAX_REQUEST_LENGTH +
LWS_SEND_BUFFER_POST_PADDING];
const char *payload;
+ jobj = json_object_new_object();
+ if (jobj == NULL) {
+ LOGE("cannot create json object\n");
+ return;
+ }
+
memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, MAX_REQUEST_LENGTH);
json_object_object_add(jobj, "id", json_object_new_int(request_id++));