svn commit: r326052 - head/usr.bin/gzip

2017-11-21 Thread Xin LI
Author: delphij
Date: Tue Nov 21 08:14:30 2017
New Revision: 326052
URL: https://svnweb.freebsd.org/changeset/base/326052

Log:
  Support SIGINFO.
  
  Obtained from:NetBSD
  MFC after:2 weeks

Modified:
  head/usr.bin/gzip/gzip.1
  head/usr.bin/gzip/gzip.c
  head/usr.bin/gzip/unbzip2.c
  head/usr.bin/gzip/unpack.c
  head/usr.bin/gzip/unxz.c

Modified: head/usr.bin/gzip/gzip.1
==
--- head/usr.bin/gzip/gzip.1Tue Nov 21 07:35:29 2017(r326051)
+++ head/usr.bin/gzip/gzip.1Tue Nov 21 08:14:30 2017(r326052)
@@ -1,6 +1,6 @@
-.\"$NetBSD: gzip.1,v 1.26 2015/10/27 07:36:18 mrg Exp $
+.\"$NetBSD: gzip.1,v 1.30 2017/10/22 17:36:49 abhinav Exp $
 .\"
-.\" Copyright (c) 1997, 2003, 2004 Matthew R. Green
+.\" Copyright (c) 1997, 2003, 2004, 2008, 2009, 2015, 2017 Matthew R. Green
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -25,11 +25,13 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd October 26, 2015
+.Dd November 21, 2017
 .Dt GZIP 1
 .Os
 .Sh NAME
-.Nm gzip
+.Nm gzip ,
+.Nm gunzip ,
+.Nm zcat
 .Nd compression/decompression tool using Lempel-Ziv coding (LZ77)
 .Sh SYNOPSIS
 .Nm
@@ -112,67 +114,68 @@ or
 .Sh OPTIONS
 The following options are available:
 .Bl -tag -width XXrXXXrecursiveX
-.It Fl 1 , -fast
+.It Fl 1 , Fl Fl fast
 .It Fl 2 , 3 , 4 , 5 , 6 , 7 , 8
-.It Fl 9 , -best
+.It Fl 9 , Fl Fl best
 These options change the compression level used, with the
 .Fl 1
 option being the fastest, with less compression, and the
 .Fl 9
 option being the slowest, with optimal compression.
 The default compression level is 6.
-.It Fl c , -stdout , -to-stdout
+.It Fl c , Fl Fl stdout , Fl Fl to-stdout
 This option specifies that output will go to the standard output
 stream, leaving files intact.
-.It Fl d , -decompress , -uncompress
+.It Fl d , Fl Fl decompress , Fl Fl uncompress
 This option selects decompression rather than compression.
-.It Fl f , -force
+.It Fl f , Fl Fl force
 This option turns on force mode.
 This allows files with multiple links, symbolic links to regular files,
 overwriting of pre-existing files, reading from or writing to a terminal,
 and when combined with the
 .Fl c
 option, allowing non-compressed data to pass through unchanged.
-.It Fl h , -help
+.It Fl h , Fl Fl help
 This option prints a usage summary and exits.
-.It Fl k , -keep
-Keep (do not delete) input files during compression
-or decompression.
+.It Fl k , Fl Fl keep
+This option prevents
+.Nm
+from deleting input files after (de)compression.
 .It Fl L , -license
 This option prints
 .Nm
 license.
-.It Fl l , -list
+.It Fl l , Fl Fl list
 This option displays information about the file's compressed and
 uncompressed size, ratio, uncompressed name.
 With the
 .Fl v
 option, it also displays the compression method, CRC, date and time
 embedded in the file.
-.It Fl N , -name
+.It Fl N , Fl Fl name
 This option causes the stored filename in the input file to be used
 as the output file.
-.It Fl n , -no-name
+.It Fl n , Fl Fl no-name
 This option stops the filename and timestamp from being stored in
 the output file.
-.It Fl q , -quiet
+.It Fl q , Fl Fl quiet
 With this option, no warnings or errors are printed.
-.It Fl r , -recursive
+.It Fl r , Fl Fl recursive
 This option is used to
 .Nm
 the files in a directory tree individually, using the
 .Xr fts 3
 library.
-.It Fl S Ar suffix , Fl -suffix Ar suffix
+.It Fl S Ar suffix , Fl Fl suffix Ar suffix
 This option changes the default suffix from .gz to
 .Ar suffix .
-.It Fl t , -test
+.It Fl t , Fl Fl test
 This option will test compressed files for integrity.
-.It Fl V , -version
+.It Fl V , Fl Fl version
 This option prints the version of the
 .Nm
 program.
-.It Fl v , -verbose
+.It Fl v , Fl Fl verbose
 This option turns on verbose mode, which prints the compression
 ratio for each file compressed.
 .El
@@ -189,6 +192,13 @@ The
 utility exits 0 on success,
 1 on errors,
 and 2 if a warning occurs.
+.Sh SIGNALS
+.Nm
+responds to the following signals:
+.Bl -tag -width indent
+.It Dv SIGINFO
+Report progress to standard error.
+.El
 .Sh SEE ALSO
 .Xr bzip2 1 ,
 .Xr compress 1 ,
@@ -213,7 +223,8 @@ This implementation of
 .Nm
 was ported based on the
 .Nx
-.Nm ,
+.Nm
+version 20170803,
 and first appeared in
 .Fx 7.0 .
 .Sh AUTHORS

Modified: head/usr.bin/gzip/gzip.c
==
--- head/usr.bin/gzip/gzip.cTue Nov 21 07:35:29 2017(r326051)
+++ head/usr.bin/gzip/gzip.cTue Nov 21 08:14:30 2017(r326052)
@@ -1,7 +1,8 @@
-/* $NetBSD: gzip.c,v 1.109 2015/10/27 07:36:18 mrg Exp $   */
+/* $NetBSD: gzip.c,v 1.112 2017/08/23 13:04:17 christos Exp $  */
 
 /*-
- * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green
+ * Copyright (c) 1997, 1998, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2015, 
2017
+ *Matthew R. Green

Re: svn commit: r326052 - head/usr.bin/gzip

2020-03-10 Thread Conrad Meyer
Hi Xin Li,

Sorry to reply to an old commit.

On Tue, Nov 21, 2017 at 12:14 AM Xin LI  wrote:
>
> Author: delphij
> Date: Tue Nov 21 08:14:30 2017
> New Revision: 326052
> URL: https://svnweb.freebsd.org/changeset/base/326052
>
> Log:
>   Support SIGINFO.
> ...
> --- head/usr.bin/gzip/unpack.c  Tue Nov 21 07:35:29 2017(r326051)
> +++ head/usr.bin/gzip/unpack.c  Tue Nov 21 08:14:30 2017(r326052)
> ...
> @@ -152,6 +155,9 @@ 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");

This check should perhaps be >=, rather than >.

> +
> /* Prepend the header buffer if we already read some data */
> if (prelen != 0)
> memcpy(hdr, pre, prelen);
> @@ -160,6 +166,7 @@ unpack_parse_header(int in, int out, char *pre, size_t
> bytesread = read(in, hdr + prelen, PACK_HEADER_LENGTH - prelen);

In the case where prelen == sizeof(hdr), we invoke read(, pointer past
end of hdr, 0) above.  This should have no effect, but looks
unintended, and tickles Coverity (CID 1383554).

> if (bytesread < 0)
> maybe_err("Error reading pack header");

Best,
Conrad
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326052 - head/usr.bin/gzip

2020-03-11 Thread Xin Li
On 3/10/20 18:26, Conrad Meyer wrote:
> Hi Xin Li,
> 
> Sorry to reply to an old commit.
> 
> On Tue, Nov 21, 2017 at 12:14 AM Xin LI  wrote:
>>
>> Author: delphij
>> Date: Tue Nov 21 08:14:30 2017
>> New Revision: 326052
>> URL: https://svnweb.freebsd.org/changeset/base/326052
>>
>> Log:
>>   Support SIGINFO.
>> ...
>> --- head/usr.bin/gzip/unpack.c  Tue Nov 21 07:35:29 2017(r326051)
>> +++ head/usr.bin/gzip/unpack.c  Tue Nov 21 08:14:30 2017(r326052)
>> ...
>> @@ -152,6 +155,9 @@ 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");
> 
> This check should perhaps be >=, rather than >.
> 
>> +
>> /* Prepend the header buffer if we already read some data */
>> if (prelen != 0)
>> memcpy(hdr, pre, prelen);
>> @@ -160,6 +166,7 @@ unpack_parse_header(int in, int out, char *pre, size_t
>> bytesread = read(in, hdr + prelen, PACK_HEADER_LENGTH - prelen);
> 
> In the case where prelen == sizeof(hdr), we invoke read(, pointer past
> end of hdr, 0) above.  This should have no effect, but looks
> unintended, and tickles Coverity (CID 1383554).

Thanks for the analysis.  It seems that this is a false positive because
the situation can never happen with the current code (the passed prelen
has to be either 0 or 4).

I've created a changeset at: https://reviews.freebsd.org/D24034 to
address it.

Cheers,





signature.asc
Description: OpenPGP digital signature