summaryrefslogtreecommitdiff
path: root/src/menus.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2008-04-19 17:53:56 +0200
committerMatthieu Herrb <matthieu@bluenote.herrb.net>2008-04-19 17:53:56 +0200
commit22290b3051b90ee8b791be23a6d82595a06704ac (patch)
tree67557abe482307abda545bc9513f38c1119064ba /src/menus.c
parentbe2debd6e9f6a27bf574435591e38c9590af0f62 (diff)
Itojun's patches to remove sprintf(), strcpy() and strcat().
Diffstat (limited to 'src/menus.c')
-rw-r--r--src/menus.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/menus.c b/src/menus.c
index d91dd24..eaf9cf9 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -1983,8 +1983,8 @@ ExecuteFunction(int func, char *action, Window w, TwmWindow *tmp_win,
break;
case F_CUT:
- strcpy(tmp, action);
- strcat(tmp, "\n");
+ strlcpy(tmp, action, sizeof(tmp));
+ strlcat(tmp, "\n", sizeof(tmp));
XStoreBytes(dpy, tmp, strlen(tmp));
break;
@@ -2358,7 +2358,11 @@ Execute(char *s)
oldDisplay[0] = '\0';
doisplay=getenv("DISPLAY");
if (doisplay)
- strcpy (oldDisplay, doisplay);
+ if (strlcpy (oldDisplay, doisplay, sizeof(oldDisplay)) >=
+ sizeof(oldDisplay)) {
+ /* some error report? */
+ return;
+ }
/*
* Build a display string using the current screen number, so that
@@ -2368,8 +2372,8 @@ Execute(char *s)
*/
colon = strrchr (ds, ':');
if (colon) { /* if host[:]:dpy */
- strcpy (buf, "DISPLAY=");
- strcat (buf, ds);
+ strlcpy (buf, "DISPLAY=", sizeof(buf));
+ strlcat (buf, ds, sizeof(buf));
colon = buf + 8 + (colon - ds); /* use version in buf */
dot1 = strchr (colon, '.'); /* first period after colon */
if (!dot1) dot1 = colon + strlen (colon); /* if not there, append */
@@ -2381,7 +2385,7 @@ Execute(char *s)
(void) system (s);
if (restorevar) { /* why bother? */
- (void) sprintf (buf, "DISPLAY=%s", oldDisplay);
+ (void) snprintf (buf, sizeof(buf), "DISPLAY=%s", oldDisplay);
putenv (buf);
}
}