diff options
author | kris <kris@FreeBSD.org> | 2000-08-04 06:25:30 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2000-08-04 06:25:30 +0000 |
commit | 0b697dfdc6e1be4175c9c84fe306374e3fcfc7e1 (patch) | |
tree | 757125b6f826209396a368464a47cb382cd44b12 | |
parent | b9066bd4b2a7100f02b8c49223b25cab6672b3f9 (diff) | |
download | FreeBSD-src-0b697dfdc6e1be4175c9c84fe306374e3fcfc7e1.zip FreeBSD-src-0b697dfdc6e1be4175c9c84fe306374e3fcfc7e1.tar.gz |
Prevent buffer overflows.
-rw-r--r-- | lib/libz/minigzip.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libz/minigzip.c b/lib/libz/minigzip.c index ba4b2dc..e8a61b1 100644 --- a/lib/libz/minigzip.c +++ b/lib/libz/minigzip.c @@ -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) { |