summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmadeusz Sławiński <amade@asmblr.net>2012-01-05 02:09:52 +0100
committerAmadeusz Sławiński <amade@asmblr.net>2014-07-24 11:50:46 +0200
commit1c3a9f3c4f03e2ce20a8d1462a90c2c54d684e81 (patch)
tree5db73bcf0f9bc37a6281985ec1c8e0a19dd2cdf9
parent53394004a02d9cbf4b2b091ef7e60df971966499 (diff)
downloadscreen-1c3a9f3c4f03e2ce20a8d1462a90c2c54d684e81.tar.gz
strcpy -> strncpy
-rw-r--r--src/process.c34
-rw-r--r--src/screen.c8
-rw-r--r--src/socket.c4
-rw-r--r--src/termcap.c2
4 files changed, 28 insertions, 20 deletions
diff --git a/src/process.c b/src/process.c
index b3765ad..d3bcd50 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4059,7 +4059,7 @@ DoAction(struct action *act, int key)
break;
}
debug2("rename(%s, %s) done\n", SockPath, buf);
- strcpy(SockPath, buf);
+ strncpy(SockPath, buf, MAXPATHLEN + 2 * MAXSTR);
MakeNewEnv();
WindowChanged((struct win *)0, 'S');
}
@@ -6506,37 +6506,45 @@ ShowInfo()
static void
ShowDInfo()
{
- char buf[512], *p;
+ char buf[128], *p;
+ int l;
if (display == 0)
return;
p = buf;
+ l = 512;
sprintf(p, "(%d,%d)", D_width, D_height),
- p += strlen(p);
+ l -= strlen(p);
+ p += l;
if (D_encoding)
{
*p++ = ' ';
- strcpy(p, EncodingName(D_encoding));
- p += strlen(p);
+ strncpy(p, EncodingName(D_encoding), l);
+ l -= strlen(p);
+ p += l;
}
if (D_CXT)
{
- strcpy(p, " xterm");
- p += strlen(p);
+ strncpy(p, " xterm", l);
+ l -= strlen(p);
+ p += l;
}
if (D_hascolor)
{
- strcpy(p, " color");
- p += strlen(p);
+ strncpy(p, " color", l);
+ l -= strlen(p);
+ p += l;
}
if (D_CG0)
{
- strcpy(p, " iso2022");
- p += strlen(p);
+ strncpy(p, " iso2022", l);
+ l -= strlen(p);
+ p += l;
}
else if (D_CS0 && *D_CS0)
{
- strcpy(p, " altchar");
- p += strlen(p);
+ strncpy(p, " altchar", l);
+ l -= strlen(p);
+ p += l;
}
Msg(0, "%s", buf);
}
diff --git a/src/screen.c b/src/screen.c
index b0f70b4..3917b66 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -970,7 +970,7 @@ main(int argc, char **argv)
Panic(0, "Cannot make directory '%s'.", SockDir);
}
if (SockDir != SockPath)
- strcpy(SockPath, SockDir);
+ strncpy(SockPath, SockDir, MAXPATHLEN + 2 * MAXSTR);
}
#ifdef SOCKDIR
else
@@ -2591,7 +2591,7 @@ MakeWinMsgEv(char *str, struct win *win, int esc, int padlen, struct event *ev,
*p = 0;
if (win && (int)strlen(win->w_title) < l)
{
- strcpy(p, win->w_title);
+ strncpy(p, win->w_title, l);
if (*p)
qmflag = 1;
}
@@ -2628,7 +2628,7 @@ MakeWinMsgEv(char *str, struct win *win, int esc, int padlen, struct event *ev,
*p = 0;
if ((int)strlen(HostName) < l)
{
- strcpy(p, HostName);
+ strncpy(p, HostName, l);
if (*p)
qmflag = 1;
}
@@ -2641,7 +2641,7 @@ MakeWinMsgEv(char *str, struct win *win, int esc, int padlen, struct event *ev,
session_name = strchr(SockName, '.') + 1;
if ((int)strlen(session_name) < l)
{
- strcpy(p, session_name);
+ strncpy(p, session_name, l);
if (*p)
qmflag = 1;
}
diff --git a/src/socket.c b/src/socket.c
index fdc5726..b05313c 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1099,9 +1099,9 @@ ReceiveMsg()
case MSG_QUERY:
{
char *oldSockPath = SaveStr(SockPath);
- strcpy(SockPath, m.m.command.writeback);
+ strncpy(SockPath, m.m.command.writeback, MAXPATHLEN + 2 * MAXSTR);
int s = MakeClientSocket(0);
- strcpy(SockPath, oldSockPath);
+ strncpy(SockPath, oldSockPath, MAXPATHLEN + 2 * MAXSTR);
Free(oldSockPath);
if (s >= 0)
{
diff --git a/src/termcap.c b/src/termcap.c
index a4c78bd..b59e7d2 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -829,7 +829,7 @@ MakeTermcap(int aflag)
if (*screenterm == '\0' || strlen(screenterm) > MAXSTR - 3)
{
debug("MakeTermcap sets screenterm=screen\n");
- strcpy(screenterm, "screen");
+ strncpy(screenterm, "screen", 20);
}
do
{