summaryrefslogtreecommitdiffstats
path: root/bin/ed
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2015-12-18 21:58:42 +0000
committerpfg <pfg@FreeBSD.org>2015-12-18 21:58:42 +0000
commit0ba92f8ec128fc6965986160d6115ebd38484371 (patch)
tree9df0ded00e2c48a18e3247aa0207ed5db6780dcc /bin/ed
parent429291909c26af343690770fe6f943bf3d5c1cf0 (diff)
downloadFreeBSD-src-0ba92f8ec128fc6965986160d6115ebd38484371.zip
FreeBSD-src-0ba92f8ec128fc6965986160d6115ebd38484371.tar.gz
ed(1): Prevent possible string overflows
CID: 1007252 MFC after: 2 weeks
Diffstat (limited to 'bin/ed')
-rw-r--r--bin/ed/main.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/ed/main.c b/bin/ed/main.c
index 98bb300..138c183 100644
--- a/bin/ed/main.c
+++ b/bin/ed/main.c
@@ -505,7 +505,8 @@ exec_command(void)
return ERR;
else if (open_sbuf() < 0)
return FATAL;
- if (*fnp && *fnp != '!') strcpy(old_filename, fnp);
+ if (*fnp && *fnp != '!')
+ strncpy(old_filename, fnp, PATH_MAX);
#ifdef BACKWARDS
if (*fnp == '\0' && *old_filename == '\0') {
errmsg = "no current filename";
@@ -532,7 +533,8 @@ exec_command(void)
return ERR;
}
GET_COMMAND_SUFFIX();
- if (*fnp) strcpy(old_filename, fnp);
+ if (*fnp)
+ strncpy(old_filename, fnp, PATH_MAX);
printf("%s\n", strip_escapes(old_filename));
break;
case 'g':
@@ -663,7 +665,7 @@ exec_command(void)
GET_COMMAND_SUFFIX();
if (!isglobal) clear_undo_stack();
if (*old_filename == '\0' && *fnp != '!')
- strcpy(old_filename, fnp);
+ strncpy(old_filename, fnp, PATH_MAX);
#ifdef BACKWARDS
if (*fnp == '\0' && *old_filename == '\0') {
errmsg = "no current filename";
@@ -797,7 +799,7 @@ exec_command(void)
return ERR;
GET_COMMAND_SUFFIX();
if (*old_filename == '\0' && *fnp != '!')
- strcpy(old_filename, fnp);
+ strncpy(old_filename, fnp, PATH_MAX);
#ifdef BACKWARDS
if (*fnp == '\0' && *old_filename == '\0') {
errmsg = "no current filename";
OpenPOWER on IntegriCloud