diff --git a/src/bin/e.h b/src/bin/e.h index 3f4214440..0b6970f3a 100644 --- a/src/bin/e.h +++ b/src/bin/e.h @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c index b25115a9e..7e9e9d1f2 100644 --- a/src/bin/e_actions.c +++ b/src/bin/e_actions.c @@ -2148,15 +2148,13 @@ _delayed_action_list_parse(Delayed_Action *da, const char *params) const char *action, *params; a1 = alloca(a1stop - a1start + 1); - strncpy(a1, a1start, a1stop - a1start); - a1[a1stop - a1start] = 0; + ecore_strlcpy(a1, a1start, a1stop - a1start + 1); action = NULL; params = NULL; _delayed_action_list_parse_action(a1, &delay, &da->def.action, &da->def.params); a2 = alloca(a1stop - a1start + 1); - strncpy(a2, a2start, a2stop - a2start); - a2[a2stop - a2start] = 0; + ecore_strlcpy(a2, a2start, a2stop - a2start + 1); _delayed_action_list_parse_action(a2, &delay, &da->delayed.action, &da->delayed.params); } da->timer = ecore_timer_add(delay, _delayed_action_cb_timer, da); diff --git a/src/bin/e_desklock.c b/src/bin/e_desklock.c index 1acefeff2..1044e109c 100644 --- a/src/bin/e_desklock.c +++ b/src/bin/e_desklock.c @@ -701,8 +701,8 @@ _desklock_auth(char *passwd) sigaction(SIGABRT, &action, NULL); current_user = _desklock_auth_get_current_user(); - strncpy(da.user, current_user, PATH_MAX); - strncpy(da.passwd, passwd, PATH_MAX); + ecore_strlcpy(da.user, current_user, PATH_MAX); + ecore_strlcpy(da.passwd, passwd, PATH_MAX); /* security - null out passwd string once we are done with it */ for (p = passwd; *p; p++) *p = 0; da.pam.handle = NULL; diff --git a/src/bin/e_eap_editor.c b/src/bin/e_eap_editor.c index 1280d055d..4621ed435 100644 --- a/src/bin/e_eap_editor.c +++ b/src/bin/e_eap_editor.c @@ -402,7 +402,7 @@ _e_desktop_edit_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfd basename[i] = '\0'; } else - strncpy(basename, "unnamed_desktop", sizeof(basename)); + ecore_strlcpy(basename, "unnamed_desktop", sizeof(basename)); i = 0; snprintf(path, sizeof(path), "%s/applications/%s.desktop", diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 175466ff4..a92f5d38b 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -3738,9 +3738,8 @@ _e_fm2_icon_label_set(E_Fm2_Icon *ic, Evas_Object *obj) * also be fuzzy - up to 4 chars of extn is ok - eg .html but 5 or * more is considered part of the name */ - strncpy(buf, ic->info.file, sizeof(buf) - 2); - buf[sizeof(buf) - 1] = 0; - + ecore_strlcpy(buf, ic->info.file, sizeof(buf)); + len = strlen(buf); p = strrchr(buf, '.'); if ((p) && ((len - (p - buf)) < 6)) @@ -5962,10 +5961,8 @@ _e_fm2_cb_icon_sort(const void *data1, const void *data2) } else */ { - strncpy(buf1, l1, sizeof(buf1) - 2); - strncpy(buf2, l2, sizeof(buf2) - 2); - buf1[sizeof(buf1) - 1] = 0; - buf2[sizeof(buf2) - 1] = 0; + ecore_strlcpy(buf1, l1, sizeof(buf1)); + ecore_strlcpy(buf2, l2, sizeof(buf2)); } p = buf1; while (*p) diff --git a/src/bin/e_fm_mime.c b/src/bin/e_fm_mime.c index 3423d5eeb..3a98dfaeb 100644 --- a/src/bin/e_fm_mime.c +++ b/src/bin/e_fm_mime.c @@ -48,8 +48,7 @@ e_fm_mime_icon_get(const char *mime) val = evas_hash_find(icon_map, mime); if (val) return val; - strncpy(buf2, mime, sizeof(buf2) - 1); - buf2[sizeof(buf2) - 1] = 0; + ecore_strlcpy(buf2, mime, sizeof(buf2)); val = strchr(buf2, '/'); if (val) *val = 0; @@ -59,8 +58,7 @@ e_fm_mime_icon_get(const char *mime) mi = l->data; if (e_util_glob_match(mi->mime, mime)) { - strncpy(buf, mi->icon, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = 0; + ecore_strlcpy(buf, mi->icon, sizeof(buf)); goto ok; } } diff --git a/src/bin/e_prefix.c b/src/bin/e_prefix.c index 6b0aeca65..dac1b13e1 100644 --- a/src/bin/e_prefix.c +++ b/src/bin/e_prefix.c @@ -91,8 +91,7 @@ e_prefix_determine(char *argv0) _prefix_path = malloc(p - _exe_path + 1); if (_prefix_path) { - strncpy(_prefix_path, _exe_path, p - _exe_path); - _prefix_path[p - _exe_path] = 0; + ecore_strlcpy(_prefix_path, _exe_path, p - _exe_path + 1); /* bin and lib always together */ snprintf(buf, sizeof(buf), "%s/bin", _prefix_path); diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c index da6cd0afe..c299b0882 100644 --- a/src/bin/e_start_main.c +++ b/src/bin/e_start_main.c @@ -84,8 +84,7 @@ prefix_determine(char *argv0) _prefix_path = malloc(p - _exe_path + 1); if (_prefix_path) { - strncpy(_prefix_path, _exe_path, p - _exe_path); - _prefix_path[p - _exe_path] = 0; + strlcpy(_prefix_path, _exe_path, p - _exe_path + 1); return 1; } else diff --git a/src/bin/e_theme.c b/src/bin/e_theme.c index b20dc592c..32137dd7c 100644 --- a/src/bin/e_theme.c +++ b/src/bin/e_theme.c @@ -197,8 +197,7 @@ e_theme_edje_object_set(Evas_Object *o, const char *category, const char *group) } } /* no mapping or set failed - fall back */ - strncpy(buf, category, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = 0; + ecore_strlcpy(buf, category, sizeof(buf)); /* shorten string up to and not including last / char */ p = strrchr(buf, '/'); if (p) *p = 0; @@ -277,8 +276,7 @@ e_theme_edje_file_get(const char *category, const char *group) } } /* no mapping or set failed - fall back */ - strncpy(buf, category, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = 0; + ecore_strlcpy(buf, category, sizeof(buf)); /* shorten string up to and not including last / char */ p = strrchr(buf, '/'); if (p) *p = 0; diff --git a/src/modules/conf_theme/e_int_config_theme.c b/src/modules/conf_theme/e_int_config_theme.c index 63394d8ee..d7e6450b8 100644 --- a/src/modules/conf_theme/e_int_config_theme.c +++ b/src/modules/conf_theme/e_int_config_theme.c @@ -758,8 +758,8 @@ _ilist_files_add(E_Config_Dialog_Data *cfdata, const char *header, const char *d e_util_edje_icon_set(ic, "enlightenment/themes"); } tmp = strdup(strrchr(themefiles->data, '/') + 1); - strncpy(themename, tmp, strlen(tmp)-3); - themename[strlen(tmp)-4] = '\0'; + strncpy(themename, tmp, strlen(tmp) - 3); + themename[strlen(tmp) - 4] = '\0'; e_widget_ilist_append(o, ic, themename, NULL, NULL, NULL); free(tmp); diff --git a/src/modules/exebuf/e_exebuf.c b/src/modules/exebuf/e_exebuf.c index dd809c7b1..2fdbec5cf 100644 --- a/src/modules/exebuf/e_exebuf.c +++ b/src/modules/exebuf/e_exebuf.c @@ -757,15 +757,13 @@ _e_exebuf_complete(void) exe = ecore_file_app_exe_get(exe_sel->desktop->exec); if (exe) { - strncpy(cmd_buf, exe, EXEBUFLEN - 1); - cmd_buf[EXEBUFLEN - 1] = 0; + ecore_strlcpy(cmd_buf, exe, EXEBUFLEN); free(exe); } } else if (exe_sel->file) { - strncpy(cmd_buf, exe_sel->file, EXEBUFLEN - 1); - cmd_buf[EXEBUFLEN - 1] = 0; + ecore_strlcpy(cmd_buf, exe_sel->file, EXEBUFLEN); } } else @@ -805,8 +803,7 @@ _e_exebuf_complete(void) } if ((exe) && (orig_len < common_len) && (common_len < (EXEBUFLEN - 1))) { - strncpy(cmd_buf, exe, common_len); - cmd_buf[common_len] = 0; + ecore_strlcpy(cmd_buf, exe, common_len + 1); } if (clear_hist) _e_exebuf_hist_clear(); diff --git a/src/modules/ibar/e_mod_main.c b/src/modules/ibar/e_mod_main.c index e7d88d78d..c04afff04 100644 --- a/src/modules/ibar/e_mod_main.c +++ b/src/modules/ibar/e_mod_main.c @@ -278,7 +278,7 @@ _ibar_new(Evas *evas, Instance *inst) snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, inst->ci->dir); } else - snprintf(buf, sizeof(buf), inst->ci->dir); + ecore_strlcpy(buf, inst->ci->dir, sizeof(buf)); b->apps = e_order_new(buf); e_order_update_callback_set(b->apps, _ibar_cb_app_change, b); _ibar_fill(b); @@ -506,7 +506,7 @@ _ibar_config_update(Config_Item *ci) snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, inst->ci->dir); } else - snprintf(buf, sizeof(buf), inst->ci->dir); + ecore_strlcpy(buf, inst->ci->dir, sizeof(buf)); inst->ibar->apps = e_order_new(buf); _ibar_fill(inst->ibar); _ibar_resize_handle(inst->ibar); diff --git a/src/modules/illume/e_mod_win.c b/src/modules/illume/e_mod_win.c index 97a764337..b0f4a2275 100644 --- a/src/modules/illume/e_mod_win.c +++ b/src/modules/illume/e_mod_win.c @@ -359,8 +359,7 @@ _desktop_run(Efreet_Desktop *desktop) exename = malloc(p - desktop->exec + 1); if (exename) { - strncpy(exename, desktop->exec, p - desktop->exec); - exename[p - desktop->exec] = 0; + ecore_strlcpy(exename, desktop->exec, p - desktop->exec + 1); } } if (exename) diff --git a/src/modules/illume/wifiget.c b/src/modules/illume/wifiget.c index 4060b529f..1bc74bd83 100644 --- a/src/modules/illume/wifiget.c +++ b/src/modules/illume/wifiget.c @@ -23,7 +23,7 @@ static int link_ext_get(int fd, const char *name, int req, struct iwreq *rq) { - strncpy(rq->ifr_name, name, sizeof(rq->ifr_name)); + ecore_strlcpy(rq->ifr_name, name, sizeof(rq->ifr_name)); return (ioctl(fd, req, rq)); } diff --git a/src/modules/wizard/page_030.c b/src/modules/wizard/page_030.c index aaa27206d..aa6707c6f 100644 --- a/src/modules/wizard/page_030.c +++ b/src/modules/wizard/page_030.c @@ -121,8 +121,7 @@ wizard_page_show(E_Wizard_Page *pg) tlabel = malloc(p2 - p + 1); if (tlabel) { - strncpy(tlabel, p, p2 - p); - tlabel[p2 - p] = 0; + ecore_strlcpy(tlabel, p, p2 - p + 1); tlabel[0] = toupper(tlabel[0]); if (*p2 == '-') { @@ -133,8 +132,7 @@ wizard_page_show(E_Wizard_Page *pg) tdesc = malloc(p - p2 + 1); if (tdesc) { - strncpy(tdesc, p2, p - p2); - tdesc[p - p2] = 0; + ecore_strlcpy(tdesc, p2, p - p2 + 1); tdesc[0] = toupper(tdesc[0]); snprintf(buf, sizeof(buf), "%s (%s)", tlabel, tdesc); }