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 a32a4e42ac
commit a62d4b84fd

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();