[git] GnuPG - branch, master, updated. gnupg-2.1.14-74-g70b5d7c

by Werner Koch cvs at cvs.gnupg.org
Thu Aug 11 21:36:54 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  70b5d7c43a57a44dad60c2c700a263610748d8f4 (commit)
       via  0698324cde3e0cef7eeb6cfd1640c5eefdf13698 (commit)
      from  72fa314b71e4ce8780f59b16d32cabf5d4bd5451 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 70b5d7c43a57a44dad60c2c700a263610748d8f4
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 11 21:31:12 2016 +0200

    gpg: New option --input-size-hint.
    
    * g10/options.h: Include stdint.h.
    (struct opt): Add field 'input_size_hint'.
    * g10/gpg.c (oInputSizeHint): New.
    (opts): Add --input-size-hint.
    (main): Set opt.input_size_hint.
    * g10/progress.c (write_status_progress): Use the hint.
    --
    
    This is a prerequisite to fix
    GnuPG-bug-id: 2368
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/doc/gpg.texi b/doc/gpg.texi
index 944734b..894d384 100644
--- a/doc/gpg.texi
+++ b/doc/gpg.texi
@@ -2155,6 +2155,15 @@ works properly with such messages, there is often a desire to set a
 maximum file size that will be generated before processing is forced to
 stop by the OS limits. Defaults to 0, which means "no limit".
 
+ at item --input-size-hint @var{n}
+ at opindex input-size-hint
+This option can be used to tell GPG the size of the input data in
+bytes.  @var{n} must be a positive base-10 number.  This option is
+only useful if the input is not taken from a file.  GPG may use thos
+hint to optimize its buffer allocation strategy.  It is also used by
+the @option{--status-fd} line ``PROGRESS'' to provide a value for
+``total'' if that is not available by other means.
+
 @item --import-options @code{parameters}
 @opindex import-options
 This is a space or comma delimited string that gives options for
diff --git a/g10/gpg.c b/g10/gpg.c
index adc32f0..fd21fde 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -99,6 +99,7 @@ enum cmd_and_opt_values
     aListSecretKeys = 'K',
     oBatch	  = 500,
     oMaxOutput,
+    oInputSizeHint,
     oSigNotation,
     oCertNotation,
     oShowNotation,
@@ -554,6 +555,7 @@ static ARGPARSE_OPTS opts[] = {
 
   ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
   ARGPARSE_p_u (oMaxOutput, "max-output", "@"),
+  ARGPARSE_s_s (oInputSizeHint, "input-size-hint", "@"),
 
   ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
   ARGPARSE_s_n (oQuiet,	  "quiet",   "@"),
@@ -2459,7 +2461,13 @@ main (int argc, char **argv)
 
 	  case oArmor: opt.armor = 1; opt.no_armor=0; break;
 	  case oOutput: opt.outfile = pargs.r.ret_str; break;
+
 	  case oMaxOutput: opt.max_output = pargs.r.ret_ulong; break;
+
+          case oInputSizeHint:
+            opt.input_size_hint = string_to_u64 (pargs.r.ret_str);
+            break;
+
 	  case oQuiet: opt.quiet = 1; break;
 	  case oNoTTY: tty_no_terminal(1); break;
 	  case oDryRun: opt.dry_run = 1; break;
diff --git a/g10/options.h b/g10/options.h
index d1c3634..230c96a 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -23,6 +23,7 @@
 
 #include <sys/types.h>
 #include <types.h>
+#include <stdint.h>
 #include "main.h"
 #include "packet.h"
 #include "tofu.h"
@@ -54,6 +55,12 @@ struct
   char *outfile;
   estream_t outfp;  /* Hack, sometimes used in place of outfile.  */
   off_t max_output;
+
+  /* If > 0 a hint with the expected number of input data bytes.  This
+   * is not necessary an exact number but intended to be used for
+   * progress info and to decide on how to allocate buffers.  */
+  uint64_t input_size_hint;
+
   int dry_run;
   int autostart;
   int list_only;
diff --git a/g10/progress.c b/g10/progress.c
index efc3b3a..f151657 100644
--- a/g10/progress.c
+++ b/g10/progress.c
@@ -73,11 +73,12 @@ release_progress_context (progress_filter_context_t *pfx)
 
 static void
 write_status_progress (const char *what,
-                       unsigned long current, unsigned long total)
+                       unsigned long current, unsigned long total_arg)
 {
   char buffer[60];
   char units[] = "BKMGTPEZY?";
   int unitidx = 0;
+  uint64_t total = total_arg;
 
   /* Although we use an unsigned long for the values, 32 bit
    * applications using GPGME will use an "int" and thus are limited
@@ -91,6 +92,10 @@ write_status_progress (const char *what,
    * thus scaling CURRENT and TOTAL down before they get to large,
    * should not have a noticeable effect except for rounding
    * imprecision. */
+
+  if (!total && opt.input_size_hint)
+    total = opt.input_size_hint;
+
   if (total)
     {
       if (current > total)
@@ -116,7 +121,7 @@ write_status_progress (const char *what,
     unitidx = 9;
 
   snprintf (buffer, sizeof buffer, "%.20s ? %lu %lu %c%s",
-            what? what : "?", current, total,
+            what? what : "?", current, (unsigned long)total,
             units[unitidx],
             unitidx? "iB" : "");
   write_status_text (STATUS_PROGRESS, buffer);

commit 0698324cde3e0cef7eeb6cfd1640c5eefdf13698
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Aug 11 20:46:51 2016 +0200

    common: New function string_to_u64.
    
    * common/stringhelp.c (string_to_u64): New.
    * dirmngr/http.c (longcounter_t): Remove.
    (struct cookie_s): Change content_length to uint64_t.
    (parse_response): Use string_to_u64.
    --
    
    Meanwhile we allow some C99 features including stdint.h.  Thus we can
    simplify things now.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c
index b1b56f3..943f20a 100644
--- a/common/exechelp-posix.c
+++ b/common/exechelp-posix.c
@@ -36,9 +36,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
+#include <stdint.h>
 #include <string.h>
 #include <errno.h>
 #include <assert.h>
diff --git a/common/stringhelp.c b/common/stringhelp.c
index 990fc35..b5d9f4c 100644
--- a/common/stringhelp.c
+++ b/common/stringhelp.c
@@ -58,6 +58,7 @@
 
 #define tohex_lower(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'a'))
 
+
 /* Sometimes we want to avoid mixing slashes and backslashes on W32
    and prefer backslashes.  There is usual no problem with mixing
    them, however a very few W32 API calls can't grok plain slashes.
@@ -660,6 +661,25 @@ compare_filenames (const char *a, const char *b)
 }
 
 
+/* Convert a base-10 number in STRING into a 64 bit unsigned int
+ * value.  Leading white spaces are skipped but no error checking is
+ * done.  Thus it is similar to atoi(). */
+uint64_t
+string_to_u64 (const char *string)
+{
+  uint64_t val = 0;
+
+  while (spacep (string))
+    string++;
+  for (; digitp (string); string++)
+    {
+      val *= 10;
+      val += *string - '0';
+    }
+  return val;
+}
+
+
 /* Convert 2 hex characters at S to a byte value.  Return this value
    or -1 if there is an error. */
 int
diff --git a/common/stringhelp.h b/common/stringhelp.h
index adf2f20..79d2284 100644
--- a/common/stringhelp.h
+++ b/common/stringhelp.h
@@ -33,6 +33,7 @@
 #ifndef GNUPG_COMMON_STRINGHELP_H
 #define GNUPG_COMMON_STRINGHELP_H
 
+#include <stdint.h>
 #include "types.h"
 
 /*-- stringhelp.c --*/
@@ -59,6 +60,7 @@ char *make_absfilename_try (const char *first_part,
                             ...) GPGRT_ATTR_SENTINEL(0);
 int compare_filenames( const char *a, const char *b );
 
+uint64_t string_to_u64 (const char *string);
 int hextobyte (const char *s);
 
 size_t utf8_charcount (const char *s, int len);
diff --git a/dirmngr/http.c b/dirmngr/http.c
index a512e9a..ac8238c 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -130,15 +130,6 @@
                         "01234567890@"                 \
                         "!\"#$%&'()*+,-./:;<=>?[\\]^_{|}~"
 
-/* A long counter type.  */
-#ifdef HAVE_STRTOULL
-typedef unsigned long long longcounter_t;
-# define counter_strtoul(a) strtoull ((a), NULL, 10)
-#else
-typedef unsigned long longcounter_t;
-# define counter_strtoul(a) strtoul ((a), NULL, 10)
-#endif
-
 #if HTTP_USE_NTBTLS
 typedef ntbtls_t         tls_session_t;
 # define USE_TLS 1
@@ -206,7 +197,7 @@ struct cookie_s
 
   /* The remaining content length and a flag telling whether to use
      the content length.  */
-  longcounter_t content_length;
+  uint64_t content_length;
   unsigned int content_length_valid:1;
 };
 typedef struct cookie_s *cookie_t;
@@ -2170,7 +2161,7 @@ parse_response (http_t hd)
       if (s)
         {
           cookie->content_length_valid = 1;
-          cookie->content_length = counter_strtoul (s);
+          cookie->content_length = string_to_u64 (s);
         }
     }
 

-----------------------------------------------------------------------

Summary of changes:
 common/exechelp-posix.c |  4 +---
 common/stringhelp.c     | 20 ++++++++++++++++++++
 common/stringhelp.h     |  2 ++
 dirmngr/http.c          | 13 ++-----------
 doc/gpg.texi            |  9 +++++++++
 g10/gpg.c               |  8 ++++++++
 g10/options.h           |  7 +++++++
 g10/progress.c          |  9 +++++++--
 8 files changed, 56 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list