summaryrefslogtreecommitdiffstats
path: root/bin/mv/mv.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-06-09 03:39:38 +0000
committerimp <imp@FreeBSD.org>1998-06-09 03:39:38 +0000
commitbfab679fddfc39a9506c7176713baa8fdf2c108c (patch)
treec32f046e4f5b8952463667eea9308a3e536334aa /bin/mv/mv.c
parentc530c6747abadfbfd17a453f17fb6f28f550fc7f (diff)
downloadFreeBSD-src-bfab679fddfc39a9506c7176713baa8fdf2c108c.zip
FreeBSD-src-bfab679fddfc39a9506c7176713baa8fdf2c108c.tar.gz
Make sure we don't overflow the path buffer. Exit if we do.
Obtained from or inspired by: A similar change in OpenBSD by theo
Diffstat (limited to 'bin/mv/mv.c')
-rw-r--r--bin/mv/mv.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 2963cff..20f4a27 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -45,7 +45,7 @@ static char const copyright[] =
static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
- "$Id: mv.c,v 1.18 1998/05/15 06:25:17 charnier Exp $";
+ "$Id: mv.c,v 1.19 1998/05/25 22:44:16 steve Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -80,7 +80,7 @@ main(argc, argv)
register char *p, *endp;
struct stat sb;
int ch;
- char path[MAXPATHLEN + 1];
+ char path[MAXPATHLEN];
while ((ch = getopt(argc, argv, "fi")) != -1)
switch (ch) {
@@ -112,6 +112,8 @@ main(argc, argv)
}
/* It's a directory, move each file into it. */
+ if (strlen(argv[argc - 1]) > sizeof(path) - 1)
+ errx(1, "%s: destination pathname too long", *argv);
(void)strcpy(path, argv[argc - 1]);
baselen = strlen(path);
endp = &path[baselen];
OpenPOWER on IntegriCloud