svn commit: r360186 - stable/12/usr.bin/gzip
Xin LI
delphij at FreeBSD.org
Wed Apr 22 05:54:47 UTC 2020
Author: delphij
Date: Wed Apr 22 05:54:46 2020
New Revision: 360186
URL: https://svnweb.freebsd.org/changeset/base/360186
Log:
MFC r358988: Remove unneeded checks for prelen.
Modified:
stable/12/usr.bin/gzip/gzip.c
stable/12/usr.bin/gzip/unlz.c
stable/12/usr.bin/gzip/unpack.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/usr.bin/gzip/gzip.c
==============================================================================
--- stable/12/usr.bin/gzip/gzip.c Wed Apr 22 05:14:52 2020 (r360185)
+++ stable/12/usr.bin/gzip/gzip.c Wed Apr 22 05:54:46 2020 (r360186)
@@ -1443,7 +1443,7 @@ file_uncompress(char *file, char *outfile, size_t outs
struct stat isb, osb;
off_t size;
ssize_t rbytes;
- unsigned char header1[4];
+ unsigned char fourbytes[4];
enum filetype method;
int fd, ofd, zfd = -1;
int error;
@@ -1477,8 +1477,8 @@ file_uncompress(char *file, char *outfile, size_t outs
goto lose;
}
- rbytes = read(fd, header1, sizeof header1);
- if (rbytes != sizeof header1) {
+ rbytes = read(fd, fourbytes, sizeof fourbytes);
+ if (rbytes != sizeof fourbytes) {
/* we don't want to fail here. */
#ifndef SMALL
if (fflag)
@@ -1492,7 +1492,7 @@ file_uncompress(char *file, char *outfile, size_t outs
}
infile_newdata(rbytes);
- method = file_gettype(header1);
+ method = file_gettype(fourbytes);
#ifndef SMALL
if (fflag == 0 && method == FT_UNKNOWN) {
maybe_warnx("%s: not in gzip format", file);
@@ -1516,7 +1516,7 @@ file_uncompress(char *file, char *outfile, size_t outs
infile_newdata(rv);
timestamp = le32dec(&ts[0]);
- if (header1[3] & ORIG_NAME) {
+ if (fourbytes[3] & ORIG_NAME) {
rbytes = pread(fd, name, sizeof(name) - 1, GZIP_ORIGNAME);
if (rbytes < 0) {
maybe_warn("can't read %s", file);
@@ -1818,7 +1818,7 @@ static void
handle_stdin(void)
{
struct stat isb;
- unsigned char header1[4];
+ unsigned char fourbytes[4];
size_t in_size;
off_t usize, gsize;
enum filetype method;
@@ -1849,16 +1849,16 @@ handle_stdin(void)
goto out;
}
- bytes_read = read_retry(STDIN_FILENO, header1, sizeof header1);
+ bytes_read = read_retry(STDIN_FILENO, fourbytes, sizeof fourbytes);
if (bytes_read == -1) {
maybe_warn("can't read stdin");
goto out;
- } else if (bytes_read != sizeof(header1)) {
+ } else if (bytes_read != sizeof(fourbytes)) {
maybe_warnx("(stdin): unexpected end of file");
goto out;
}
- method = file_gettype(header1);
+ method = file_gettype(fourbytes);
switch (method) {
default:
#ifndef SMALL
@@ -1866,17 +1866,17 @@ handle_stdin(void)
maybe_warnx("unknown compression format");
goto out;
}
- usize = cat_fd(header1, sizeof header1, &gsize, STDIN_FILENO);
+ usize = cat_fd(fourbytes, sizeof fourbytes, &gsize, STDIN_FILENO);
break;
#endif
case FT_GZIP:
usize = gz_uncompress(STDIN_FILENO, STDOUT_FILENO,
- (char *)header1, sizeof header1, &gsize, "(stdin)");
+ (char *)fourbytes, sizeof fourbytes, &gsize, "(stdin)");
break;
#ifndef NO_BZIP2_SUPPORT
case FT_BZIP2:
usize = unbzip2(STDIN_FILENO, STDOUT_FILENO,
- (char *)header1, sizeof header1, &gsize);
+ (char *)fourbytes, sizeof fourbytes, &gsize);
break;
#endif
#ifndef NO_COMPRESS_SUPPORT
@@ -1886,27 +1886,27 @@ handle_stdin(void)
goto out;
}
- usize = zuncompress(in, stdout, (char *)header1,
- sizeof header1, &gsize);
+ usize = zuncompress(in, stdout, (char *)fourbytes,
+ sizeof fourbytes, &gsize);
fclose(in);
break;
#endif
#ifndef NO_PACK_SUPPORT
case FT_PACK:
usize = unpack(STDIN_FILENO, STDOUT_FILENO,
- (char *)header1, sizeof header1, &gsize);
+ (char *)fourbytes, sizeof fourbytes, &gsize);
break;
#endif
#ifndef NO_XZ_SUPPORT
case FT_XZ:
usize = unxz(STDIN_FILENO, STDOUT_FILENO,
- (char *)header1, sizeof header1, &gsize);
+ (char *)fourbytes, sizeof fourbytes, &gsize);
break;
#endif
#ifndef NO_LZ_SUPPORT
case FT_LZ:
usize = unlz(STDIN_FILENO, STDOUT_FILENO,
- (char *)header1, sizeof header1, &gsize);
+ (char *)fourbytes, sizeof fourbytes, &gsize);
break;
#endif
}
Modified: stable/12/usr.bin/gzip/unlz.c
==============================================================================
--- stable/12/usr.bin/gzip/unlz.c Wed Apr 22 05:14:52 2020 (r360185)
+++ stable/12/usr.bin/gzip/unlz.c Wed Apr 22 05:54:46 2020 (r360186)
@@ -618,8 +618,6 @@ unlz(int fin, int fout, char *pre, size_t prelen, off_
char header[HDR_SIZE];
- if (prelen > sizeof(header))
- return -1;
if (pre && prelen)
memcpy(header, pre, prelen);
Modified: stable/12/usr.bin/gzip/unpack.c
==============================================================================
--- stable/12/usr.bin/gzip/unpack.c Wed Apr 22 05:14:52 2020 (r360185)
+++ stable/12/usr.bin/gzip/unpack.c Wed Apr 22 05:54:46 2020 (r360186)
@@ -156,9 +156,6 @@ unpack_parse_header(int in, int out, char *pre, size_t
ssize_t bytesread; /* Bytes read from the file */
int i, j, thisbyte;
- if (prelen > sizeof hdr)
- maybe_err("prelen too long");
-
/* Prepend the header buffer if we already read some data */
if (prelen != 0)
memcpy(hdr, pre, prelen);
More information about the svn-src-all
mailing list