summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-05 01:03:36 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-05 01:03:36 +0000
commit6ef06ef3d19087a7d9962c574e73e4261e8d6ae6 (patch)
tree250be0b152ab1cce414937d30de55143302cb30f /usr.bin
parent39750f20d79b0fdac8c140c1bd8f7104cbf21f00 (diff)
some more string shit; krw ok
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/less/filename.c26
-rw-r--r--usr.bin/less/lesskey.c14
-rw-r--r--usr.bin/less/main.c8
-rw-r--r--usr.bin/less/regexp.c4
-rw-r--r--usr.bin/less/screen.c4
5 files changed, 32 insertions, 24 deletions
diff --git a/usr.bin/less/filename.c b/usr.bin/less/filename.c
index 71dc429e756..5c7b8ecba3e 100644
--- a/usr.bin/less/filename.c
+++ b/usr.bin/less/filename.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filename.c,v 1.4 2003/03/13 09:09:32 deraadt Exp $ */
+/* $OpenBSD: filename.c,v 1.5 2003/04/05 01:03:35 deraadt Exp $ */
/*
* Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman
@@ -329,7 +329,7 @@ readfd(fd)
len *= 2;
*p = '\0';
p = (char *) ecalloc(len, sizeof(char));
- strcpy(p, buf);
+ strlcpy(p, buf, len);
free(buf);
buf = p;
p = buf + strlen(buf);
@@ -567,7 +567,7 @@ glob(filename)
len *= 2;
*p = '\0';
p = (char *) ecalloc(len, sizeof(char));
- strcpy(p, gfilename);
+ strlcpy(p, gfilename, len);
free(gfilename);
gfilename = p;
p = gfilename + strlen(gfilename);
@@ -654,19 +654,23 @@ bad_file(filename)
if (S_ISDIR(statbuf.st_mode))
{
static char is_dir[] = " is a directory";
- m = (char *) ecalloc(strlen(filename) + sizeof(is_dir),
- sizeof(char));
- strcpy(m, filename);
- strcat(m, is_dir);
+ size_t len;
+
+ len = strlen(filename) + sizeof(is_dir);
+ m = (char *) ecalloc(len, sizeof(char));
+ strlcpy(m, filename, len);
+ strlcat(m, is_dir, len);
return (m);
}
if (!S_ISREG(statbuf.st_mode))
{
static char not_reg[] = " is not a regular file";
- m = (char *) ecalloc(strlen(filename) + sizeof(not_reg),
- sizeof(char));
- strcpy(m, filename);
- strcat(m, not_reg);
+ size_t len;
+
+ len = strlen(filename) + sizeof(not_reg);
+ m = (char *) ecalloc(len, sizeof(char));
+ strlcpy(m, filename, len);
+ strlcat(m, not_reg, len);
return (m);
}
diff --git a/usr.bin/less/lesskey.c b/usr.bin/less/lesskey.c
index ed662ada4ac..7d360954017 100644
--- a/usr.bin/less/lesskey.c
+++ b/usr.bin/less/lesskey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lesskey.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */
+/* $OpenBSD: lesskey.c,v 1.4 2003/04/05 01:03:35 deraadt Exp $ */
/*
* Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman
@@ -223,15 +223,17 @@ mkpathname(dirname, filename)
char *filename;
{
char *pathname;
+ size_t len;
- pathname = calloc(strlen(dirname) + strlen(filename) + 2, sizeof(char));
- strcpy(pathname, dirname);
+ len = strlen(dirname) + strlen(filename) + 2;
+ pathname = calloc(len, sizeof(char));
+ strlcpy(pathname, dirname, len);
#if MSOFTC || OS2
- strcat(pathname, "\\");
+ strlcat(pathname, "\\", len);
#else
- strcat(pathname, "/");
+ strlcat(pathname, "/", len);
#endif
- strcat(pathname, filename);
+ strlcat(pathname, filename, len);
return (pathname);
}
diff --git a/usr.bin/less/main.c b/usr.bin/less/main.c
index 13636365bf4..ee69c713d57 100644
--- a/usr.bin/less/main.c
+++ b/usr.bin/less/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.5 2001/11/19 19:02:14 mpech Exp $ */
+/* $OpenBSD: main.c,v 1.6 2003/04/05 01:03:35 deraadt Exp $ */
/*
* Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman
@@ -283,9 +283,11 @@ save(s)
char *s;
{
char *p;
+ size_t len;
- p = (char *) ecalloc(strlen(s)+1, sizeof(char));
- strcpy(p, s);
+ len = strlen(s)+1;
+ p = (char *) ecalloc(len, sizeof(char));
+ strlcpy(p, s, len);
return (p);
}
diff --git a/usr.bin/less/regexp.c b/usr.bin/less/regexp.c
index 41bfcf22479..c9724f4ce71 100644
--- a/usr.bin/less/regexp.c
+++ b/usr.bin/less/regexp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regexp.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */
+/* $OpenBSD: regexp.c,v 1.4 2003/04/05 01:03:35 deraadt Exp $ */
/*
* regcomp and regexec -- regsub and regerror are elsewhere
@@ -1124,7 +1124,7 @@ char *op;
char *p;
static char buf[50];
- (void) strcpy(buf, ":");
+ (void) strlcpy(buf, ":", sizeof buf);
switch (OP(op)) {
case BOL:
diff --git a/usr.bin/less/screen.c b/usr.bin/less/screen.c
index ae291b8019a..febad1966b6 100644
--- a/usr.bin/less/screen.c
+++ b/usr.bin/less/screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.c,v 1.8 2001/11/19 19:02:14 mpech Exp $ */
+/* $OpenBSD: screen.c,v 1.9 2003/04/05 01:03:35 deraadt Exp $ */
/*
* Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman
@@ -703,7 +703,7 @@ get_term()
if ((term = getenv("TERM")) == NULL)
term = DEFAULT_TERM;
if (tgetent(termbuf, term) <= 0)
- strcpy(termbuf, "dumb:hc:");
+ strlcpy(termbuf, "dumb:hc:", sizeof termbuf);
hard = tgetflag("hc");