Use strlcpy

SVN revision: 37237
This commit is contained in:
Sebastian Dransfeld 2008-10-27 12:34:35 +00:00
parent ac31380ee0
commit 10396e6085
15 changed files with 27 additions and 43 deletions

View File

@ -64,6 +64,7 @@
#include <Evas.h>
#include <Evas_Engine_Buffer.h>
#include <Ecore.h>
#include <Ecore_Str.h>
#include <Ecore_X.h>
#include <Ecore_X_Atoms.h>
#include <Ecore_X_Cursor.h>

View File

@ -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);

View File

@ -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;

View File

@ -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",

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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)

View File

@ -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));
}

View File

@ -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);
}