Don't overflow a buffer from command line arguments.

MFC after:	2 weeks
This commit is contained in:
Kris Kennaway 2001-08-20 09:43:04 +00:00
parent 3faf1df3a7
commit a0b13740e8

View File

@ -1236,8 +1236,12 @@ parseargs(argc, argv, cmd)
if (++i == argc) {
return (0);
}
(void) strcpy(pathbuf, argv[i]);
(void) strcat(pathbuf, "/cpp");
(void) strlcpy(pathbuf, argv[i], sizeof(pathbuf));
if (strlcat(pathbuf, "/cpp", sizeof(pathbuf))
>= sizeof(pathbuf)) {
warnx("argument too long");
return (0);
}
CPP = pathbuf;
cppDefined = 1;
goto nextarg;