From: Gwanglim Lee Date: Wed, 23 Mar 2016 04:58:48 +0000 (+0900) Subject: Fix the problems detected by static analyzer X-Git-Tag: submit/tizen/20160323.105531~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abc1617d40ef0719bd15d457f41cf1d67636b55f;p=platform%2Fupstream%2Fenlightenment.git Fix the problems detected by static analyzer Change-Id: Ibb4c6b496ba2a67cd8f2d2c16a30509cc5d2e2d7 --- diff --git a/src/bin/e_comp.c b/src/bin/e_comp.c index 0d1c93c194..e220cb1e77 100644 --- a/src/bin/e_comp.c +++ b/src/bin/e_comp.c @@ -1070,12 +1070,13 @@ _e_launchscreen_new(Ecore_Evas *ee) E_Launch_Screen *plscrn = NULL; EINA_SAFETY_ON_NULL_GOTO(ee, error); + EINA_SAFETY_ON_NULL_GOTO(conf, error); - if ((conf) && (conf->launch_file)) + if (conf->launch_file) { - if(!edje_file_group_exists(conf->launch_file, "e/comp/effects/launch")) - goto error; - } + if (!edje_file_group_exists(conf->launch_file, "e/comp/effects/launch")) + goto error; + } plscrn = E_NEW(E_Launch_Screen, 1); EINA_SAFETY_ON_NULL_GOTO(plscrn, error); diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index 78011a87ac..e2bc451aa2 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -3395,7 +3395,7 @@ _e_comp_wl_screenshooter_cb_shoot(struct wl_client *client EINA_UNUSED, struct w E_Comp_Wl_Buffer *buffer; struct wl_shm_buffer *shm_buffer; int stride; - void *pixels, *d; + void *pixels = NULL, *d; output = wl_resource_get_user_data(output_resource); buffer = e_comp_wl_buffer_get(buffer_resource, NULL); @@ -3430,6 +3430,7 @@ _e_comp_wl_screenshooter_cb_shoot(struct wl_client *client EINA_UNUSED, struct w if (!shm_buffer) { ERR("Could not get shm_buffer from resource"); + free(pixels); return; } @@ -3438,6 +3439,7 @@ _e_comp_wl_screenshooter_cb_shoot(struct wl_client *client EINA_UNUSED, struct w if (!d) { ERR("Could not get buffer data"); + free(pixels); return; } diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index de81e85c50..63f4b34bb4 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -376,8 +376,8 @@ _e_comp_wl_input_keymap_fd_get(off_t size) len = strlen(path); if (len < blen) { - strcpy(tmp, path); - strcat(tmp, "/e-wl-keymap-XXXXXX"); + strncpy(tmp, path, len); + strncat(tmp, "/e-wl-keymap-XXXXXX", 19); } else return -1; @@ -489,7 +489,7 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap, const char *keymap_pat return; } - strcpy(e_comp_wl->xkb.area, tmp); + strncpy(e_comp_wl->xkb.area, e_comp_wl->xkb.size - 1); free(tmp); /* send updated keymap */ diff --git a/src/bin/e_info_server.c b/src/bin/e_info_server.c index a7b0463c41..5d8d464a26 100644 --- a/src/bin/e_info_server.c +++ b/src/bin/e_info_server.c @@ -313,7 +313,7 @@ _msg_window_prop_client_append(Eldbus_Message_Iter *iter, E_Client *target_ec) { char temp[16]; snprintf(temp, sizeof(temp), "0x%x", e_client_util_win_get(child)); - strncat( transients, temp, sizeof(transients) - strlen(transients)); + strncat(transients, temp, sizeof(transients) - strlen(transients)); } } @@ -325,7 +325,7 @@ _msg_window_prop_client_append(Eldbus_Message_Iter *iter, E_Client *target_ec) char temp[32]; snprintf(temp, sizeof(temp), "[%d,%d,%d,%d] ", target_ec->shape_rects[i].x, target_ec->shape_rects[i].y, target_ec->shape_rects[i].w, target_ec->shape_rects[i].h); - strncat( shape_rects, temp, sizeof(shape_rects) - strlen(shape_rects)); + strncat(shape_rects, temp, sizeof(shape_rects) - strlen(shape_rects)); } } @@ -337,7 +337,7 @@ _msg_window_prop_client_append(Eldbus_Message_Iter *iter, E_Client *target_ec) char temp[32]; snprintf(temp, sizeof(temp), "[%d,%d,%d,%d] ", target_ec->shape_input_rects[i].x, target_ec->shape_input_rects[i].y, target_ec->shape_input_rects[i].w, target_ec->shape_input_rects[i].h); - strncat( shape_input, temp, sizeof(shape_input) - strlen(shape_input)); + strncat(shape_input, temp, sizeof(shape_input) - strlen(shape_input)); } } @@ -655,7 +655,7 @@ _e_info_server_cb_rotation_message(const Eldbus_Service_Interface *iface EINA_UN if (rot_msg == E_INFO_ROTATION_MESSAGE_SET) { /* check if rval is valid */ - if ((rval < 0) || (rval > 270) || (rval % 90 != 0)) + if ((rval > 270) || (rval % 90 != 0)) return reply; } diff --git a/src/bin/e_path.c b/src/bin/e_path.c index b4b54843d5..7f8c8f78d7 100644 --- a/src/bin/e_path.c +++ b/src/bin/e_path.c @@ -40,8 +40,8 @@ e_path_default_path_append(E_Path *ep, const char *path) return; } - strcpy(new_path, home_dir); - strcat(new_path, path + 1); + strncpy(new_path, home_dir, len1); + strncat(new_path, path + 1, len1 + len2); epd->dir = eina_stringshare_add(new_path); free(new_path); ep->default_dir_list = eina_list_append(ep->default_dir_list, epd); @@ -93,8 +93,8 @@ e_path_user_path_append(E_Path *ep, const char *path) return; } - strcpy(new_path, home_dir); - strcat(new_path, path + 1); + strncpy(new_path, home_dir, len1); + strncat(new_path, path + 1, len1 + len2); epd->dir = eina_stringshare_add(new_path); free(new_path); *(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd); @@ -136,8 +136,8 @@ e_path_user_path_prepend(E_Path *ep, const char *path) return; } - strcpy(new_path, home_dir); - strcat(new_path, path + 1); + strncpy(new_path, home_dir, len1); + strncat(new_path, path + 1, len1 + len2); epd->dir = eina_stringshare_add(new_path); free(new_path); *(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd); @@ -174,8 +174,8 @@ e_path_user_path_remove(E_Path *ep, const char *path) len2 = strlen(path); new_path = malloc(len1 + len2 + 1); if (!new_path) return; - strcpy(new_path, home_dir); - strcat(new_path, path + 1); + strncpy(new_path, home_dir, len1); + strncat(new_path, path + 1, len1 + len2); EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd) { if (epd->dir) diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c index ea9ad4b58a..648b0c2c5a 100644 --- a/src/bin/e_pixmap.c +++ b/src/bin/e_pixmap.c @@ -338,6 +338,8 @@ e_pixmap_new(E_Pixmap_Type type, ...) else pixmaps[type] = eina_hash_int32_new((Eina_Free_Cb)_e_pixmap_free); cp = _e_pixmap_new(type); + EINA_SAFETY_ON_NULL_RETURN_VAL(cp, NULL); + cp->win = xwin; eina_hash_add(pixmaps[type], &xwin, cp); #endif @@ -361,6 +363,8 @@ e_pixmap_new(E_Pixmap_Type type, ...) } cp = _e_pixmap_new(type); + EINA_SAFETY_ON_NULL_RETURN_VAL(cp, NULL); + cp->win = id; eina_hash_add(pixmaps[type], &id, cp); uuid_generate(cp->uuid); diff --git a/src/bin/e_randr2.c b/src/bin/e_randr2.c index 02a2ea2219..a004effe04 100644 --- a/src/bin/e_randr2.c +++ b/src/bin/e_randr2.c @@ -669,7 +669,7 @@ _screen_fuzzy_fallback_find(E_Config_Randr2 *cfg, const char *id) // and fall back to finding just the output name in the rel // to identifier, rather than the specific screen id name = alloca(strlen(id) + 1); - strcpy(name, id); + strncpy(name, id, strlen(id)); if ((p = strchr(name, '/'))) *p = 0; s = _screen_id_find(id); @@ -695,7 +695,7 @@ _config_screen_clone_resolve(E_Config_Randr2 *cfg, const char *id, int *x, int * if (!cs) return NULL; name = alloca(strlen(cs->id) + 1); - strcpy(name, cs->id); + strncpy(name, cs->id, strlen(cs->id)); if ((p = strchr(name, '/'))) *p = 0; s = _screen_id_find(cs->id); diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c index 83ebfb1177..ec32784b83 100644 --- a/src/modules/wl_drm/e_mod_main.c +++ b/src/modules/wl_drm/e_mod_main.c @@ -445,8 +445,8 @@ _drm_randr_create(void) free(s); continue; } - strcpy(s->id, s->info.name); - strcat(s->id, "/"); + strncpy(s->id, s->info.name, strlen(s->info.name)); + strncat(s->id, "/", 1); if (s->info.edid) strcat(s->id, s->info.edid); printf("DRM RRR: Created Screen: %s\n", s->id);