Prevent buffer overflows.

This commit is contained in:
Kris Kennaway 2000-08-04 06:25:30 +00:00
parent 2efeedfd4b
commit cd79a42a80
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64222

View File

@ -200,6 +200,11 @@ void file_compress(file, mode)
FILE *in;
gzFile out;
if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) {
fprintf(stderr, "%s: nilename too long\n", prog);
exit(1);
}
strcpy(outfile, file);
strcat(outfile, GZ_SUFFIX);
@ -231,6 +236,11 @@ void file_uncompress(file)
gzFile in;
int len = strlen(file);
if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) {
fprintf(stderr, "%s: filename too long\n", prog);
exit(1);
}
strcpy(buf, file);
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {