Avoid overflowing `fname' if the file name prefix given on the command

line is too long.

Obtained from:	OpenBSD
This commit is contained in:
tjr 2002-05-27 04:59:46 +00:00
parent 3a59030266
commit 89c62e14bd

View File

@ -147,7 +147,8 @@ main(argc, argv)
++argv;
}
if (*argv != NULL) /* File name prefix. */
(void)strcpy(fname, *argv++);
if (strlcpy(fname, *argv++, sizeof(fname)) >= sizeof(fname))
errx(EX_USAGE, "file name prefix is too long");
if (*argv != NULL)
usage();