summaryrefslogtreecommitdiffstats
path: root/usr.bin/doscmd
diff options
context:
space:
mode:
authortg <tg@FreeBSD.org>2001-06-28 12:02:45 +0000
committertg <tg@FreeBSD.org>2001-06-28 12:02:45 +0000
commitd021e1859a25ba73f0a0e3caa922f34a7a3c1077 (patch)
treef9a4c60baad4447995b77b4bb2034cc811738867 /usr.bin/doscmd
parentc88bce56d6354296c2d4a484162c2e08b1989d8c (diff)
downloadFreeBSD-src-d021e1859a25ba73f0a0e3caa922f34a7a3c1077.zip
FreeBSD-src-d021e1859a25ba73f0a0e3caa922f34a7a3c1077.tar.gz
Fix another buffer overflow.
PR: 15593 Submitted by: Przemyslaw Frasunek <venglin@lagoon.FreeBSD.lublin.pl>
Diffstat (limited to 'usr.bin/doscmd')
-rw-r--r--usr.bin/doscmd/cwd.c8
-rw-r--r--usr.bin/doscmd/cwd.h10
2 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/doscmd/cwd.c b/usr.bin/doscmd/cwd.c
index ef5635f..f7fea8e 100644
--- a/usr.bin/doscmd/cwd.c
+++ b/usr.bin/doscmd/cwd.c
@@ -225,12 +225,12 @@ dos_makepath(u_char *where, u_char *newpath)
np = newpath;
if (*where != '\\' && *where != '/') {
- ustrcpy(tmppath, d->cwd);
+ ustrncpy(tmppath, d->cwd, 1024);
if (d->cwd[1])
- ustrcat(tmppath, (u_char *)"/");
- ustrcat(tmppath, where);
+ ustrncat(tmppath, (u_char *)"/", 1024 - ustrlen(tmppath));
+ ustrncat(tmppath, where, 1024 - ustrlen(tmppath));
} else {
- ustrcpy(tmppath, where);
+ ustrncpy(tmppath, where, 1024 - ustrlen(tmppath));
}
dirs = get_entries(tmppath);
diff --git a/usr.bin/doscmd/cwd.h b/usr.bin/doscmd/cwd.h
index dfe7e4e..10d97bf 100644
--- a/usr.bin/doscmd/cwd.h
+++ b/usr.bin/doscmd/cwd.h
@@ -45,7 +45,13 @@ ustrcat(u_char *s1, u_char *s2)
}
static inline u_char *
-ustrncpy(u_char *s1, u_char *s2, unsigned n)
+ustrncat(u_char *s1, u_char *s2, size_t n)
+{
+ return((u_char *)strncat((char *)s1, (char *)s2, n));
+}
+
+static inline u_char *
+ustrncpy(u_char *s1, u_char *s2, size_t n)
{
return((u_char *)strncpy((char *)s1, (char *)s2, n));
}
@@ -57,7 +63,7 @@ ustrcmp(u_char *s1, u_char *s2)
}
static inline int
-ustrncmp(u_char *s1, u_char *s2, unsigned n)
+ustrncmp(u_char *s1, u_char *s2, size_t n)
{
return(strncmp((char *)s1, (char *)s2, n));
}
OpenPOWER on IntegriCloud