[openssl-commits] [openssl] OpenSSL_1_1_0-stable update

Andy Polyakov appro at openssl.org
Sat Apr 8 18:36:53 UTC 2017


The branch OpenSSL_1_1_0-stable has been updated
       via  70b9063cd24904fd3d0b83173c51fdcf34085967 (commit)
       via  00eae742694a87978e5e07593109f3cd895b4bc8 (commit)
      from  74c29dc6eac1f6f8a8c2ca28f8c01a43beb8c15b (commit)


- Log -----------------------------------------------------------------
commit 70b9063cd24904fd3d0b83173c51fdcf34085967
Author: Andy Polyakov <appro at openssl.org>
Date:   Fri Apr 7 22:30:13 2017 +0200

    e_os.h: omit PRIu64.
    
    PRIu64 is error-prone with BIO_printf, so introduce and stick to custom
    platform-neutral macro. 'll' allows to print 64-bit values on *all*
    supported platforms, but it's problematic with -Wformat -Werror. Hence
    use 'l' in identifiable LP64 cases.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3148)

commit 00eae742694a87978e5e07593109f3cd895b4bc8
Author: Andy Polyakov <appro at openssl.org>
Date:   Fri Apr 7 20:26:59 2017 +0200

    bio/b_print.c: drop dependency on BN config.
    
    This might seem controversial, but it doesn't actually affect anything.
    Or rather it doesn't make worse cases when it was problematic [with code
    additions to 1.1.0]. One of such rare cases is 32-bit PA-RISC target
    with *vendor* compiler.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3148)

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

Summary of changes:
 apps/enc.c            |  4 ++--
 apps/s_cb.c           |  2 +-
 apps/s_client.c       |  4 ++--
 crypto/asn1/x_int64.c |  4 ++--
 crypto/bio/b_print.c  | 44 ++++++++++++--------------------------------
 e_os.h                | 17 ++++++-----------
 6 files changed, 25 insertions(+), 50 deletions(-)

diff --git a/apps/enc.c b/apps/enc.c
index 85182dc..b11d553 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -548,8 +548,8 @@ int enc_main(int argc, char **argv)
 
     ret = 0;
     if (verbose) {
-        BIO_printf(bio_err, "bytes read   :%8"PRIu64"\n", BIO_number_read(in));
-        BIO_printf(bio_err, "bytes written:%8"PRIu64"\n", BIO_number_written(out));
+        BIO_printf(bio_err, "bytes read   :%8"BIO_PRI64"u\n", BIO_number_read(in));
+        BIO_printf(bio_err, "bytes written:%8"BIO_PRI64"u\n", BIO_number_written(out));
     }
  end:
     ERR_print_errors(bio_err);
diff --git a/apps/s_cb.c b/apps/s_cb.c
index e0acd51..afa3065 100644
--- a/apps/s_cb.c
+++ b/apps/s_cb.c
@@ -1002,7 +1002,7 @@ static char *hexencode(const unsigned char *data, size_t len)
     int ilen = (int) outlen;
 
     if (outlen < len || ilen < 0 || outlen != (size_t)ilen) {
-        BIO_printf(bio_err, "%s: %" PRIu64 "-byte buffer too large to hexencode\n",
+        BIO_printf(bio_err, "%s: %"BIO_PRI64"u-byte buffer too large to hexencode\n",
                    opt_getprog(), (uint64_t)len);
         exit(1);
     }
diff --git a/apps/s_client.c b/apps/s_client.c
index 0292e5f..2992595 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -2615,8 +2615,8 @@ static void print_stuff(BIO *bio, SSL *s, int full)
 #endif
 
         BIO_printf(bio,
-                   "---\nSSL handshake has read %" PRIu64
-                   " bytes and written %" PRIu64 " bytes\n",
+                   "---\nSSL handshake has read %"BIO_PRI64"u"
+                   " bytes and written %"BIO_PRI64"u bytes\n",
                    BIO_number_read(SSL_get_rbio(s)),
                    BIO_number_written(SSL_get_wbio(s)));
     }
diff --git a/crypto/asn1/x_int64.c b/crypto/asn1/x_int64.c
index d180a3b..e0520ff 100644
--- a/crypto/asn1/x_int64.c
+++ b/crypto/asn1/x_int64.c
@@ -79,8 +79,8 @@ static int uint64_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
                         int indent, const ASN1_PCTX *pctx)
 {
     if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
-        return BIO_printf(out, "%jd\n", *(int64_t *)pval);
-    return BIO_printf(out, "%ju\n", *(uint64_t *)pval);
+        return BIO_printf(out, "%"BIO_PRI64"d\n", *(int64_t *)pval);
+    return BIO_printf(out, "%"BIO_PRI64"u\n", *(uint64_t *)pval);
 }
 
 /* 32-bit variants */
diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c
index e91ab6d..7bbc551 100644
--- a/crypto/bio/b_print.c
+++ b/crypto/bio/b_print.c
@@ -12,18 +12,8 @@
 #include <ctype.h>
 #include "internal/numbers.h"
 #include "internal/cryptlib.h"
-#ifndef NO_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#include <openssl/bn.h>         /* To get BN_LLONG properly defined */
 #include <openssl/bio.h>
 
-#if defined(BN_LLONG) || defined(SIXTY_FOUR_BIT)
-# ifndef HAVE_LONG_LONG
-#  define HAVE_LONG_LONG 1
-# endif
-#endif
-
 /*
  * Copyright Patrick Powell 1995
  * This code is based on code written by Patrick Powell <papowell at astart.com>
@@ -37,20 +27,10 @@
 # define LDOUBLE double
 #endif
 
-#ifdef HAVE_LONG_LONG
-# if defined(_WIN32) && !defined(__GNUC__)
-#  define LLONG __int64
-# else
-#  define LLONG long long
-# endif
-#else
-# define LLONG long
-#endif
-
 static int fmtstr(char **, char **, size_t *, size_t *,
                   const char *, int, int, int);
 static int fmtint(char **, char **, size_t *, size_t *,
-                  LLONG, int, int, int, int);
+                  int64_t, int, int, int, int);
 static int fmtfp(char **, char **, size_t *, size_t *,
                  LDOUBLE, int, int, int, int);
 static int doapr_outch(char **, char **, size_t *, size_t *, int);
@@ -106,7 +86,7 @@ _dopr(char **sbuffer,
       size_t *retlen, int *truncated, const char *format, va_list args)
 {
     char ch;
-    LLONG value;
+    int64_t value;
     LDOUBLE fvalue;
     char *strvalue;
     int min;
@@ -231,7 +211,7 @@ _dopr(char **sbuffer,
                     value = va_arg(args, long int);
                     break;
                 case DP_C_LLONG:
-                    value = va_arg(args, LLONG);
+                    value = va_arg(args, int64_t);
                     break;
                 default:
                     value = va_arg(args, int);
@@ -253,13 +233,13 @@ _dopr(char **sbuffer,
                     value = (unsigned short int)va_arg(args, unsigned int);
                     break;
                 case DP_C_LONG:
-                    value = (LLONG) va_arg(args, unsigned long int);
+                    value = va_arg(args, unsigned long int);
                     break;
                 case DP_C_LLONG:
-                    value = va_arg(args, unsigned LLONG);
+                    value = va_arg(args, uint64_t);
                     break;
                 default:
-                    value = (LLONG) va_arg(args, unsigned int);
+                    value = va_arg(args, unsigned int);
                     break;
                 }
                 if (!fmtint(sbuffer, buffer, &currlen, maxlen, value,
@@ -331,9 +311,9 @@ _dopr(char **sbuffer,
                     num = va_arg(args, long int *);
                     *num = (long int)currlen;
                 } else if (cflags == DP_C_LLONG) { /* XXX */
-                    LLONG *num;
-                    num = va_arg(args, LLONG *);
-                    *num = (LLONG) currlen;
+                    int64_t *num;
+                    num = va_arg(args, int64_t *);
+                    *num = (int64_t)currlen;
                 } else {
                     int *num;
                     num = va_arg(args, int *);
@@ -434,11 +414,11 @@ static int
 fmtint(char **sbuffer,
        char **buffer,
        size_t *currlen,
-       size_t *maxlen, LLONG value, int base, int min, int max, int flags)
+       size_t *maxlen, int64_t value, int base, int min, int max, int flags)
 {
     int signvalue = 0;
     const char *prefix = "";
-    unsigned LLONG uvalue;
+    uint64_t uvalue;
     char convert[DECIMAL_SIZE(value) + 3];
     int place = 0;
     int spadlen = 0;
@@ -451,7 +431,7 @@ fmtint(char **sbuffer,
     if (!(flags & DP_F_UNSIGNED)) {
         if (value < 0) {
             signvalue = '-';
-            uvalue = 0 - (unsigned LLONG)value;
+            uvalue = 0 - (uint64_t)value;
         } else if (flags & DP_F_PLUS)
             signvalue = '+';
         else if (flags & DP_F_SPACE)
diff --git a/e_os.h b/e_os.h
index 6819271..559bf90 100644
--- a/e_os.h
+++ b/e_os.h
@@ -30,18 +30,13 @@ extern "C" {
 # endif
 
 /*
- * We need a format operator for some client tools for uint64_t.  If inttypes.h
- * isn't available or did not define it, just go with hard-coded.
+ * BIO_printf format modifier for [u]int64_t.
  */
-# if defined(OPENSSL_SYS_UEFI)
-#  define PRIu64 "Lu"
-# endif
-# ifndef PRIu64
-#  ifdef SIXTY_FOUR_BIT_LONG
-#   define PRIu64 "lu"
-#  else
-#   define PRIu64 "llu"
-#  endif
+# if defined(__LP64__) || (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__==8)
+#  define BIO_PRI64 "l"     /* 'll' does work "universally", but 'l' is
+                             * here to shut -Wformat warnings in LP64... */
+# else
+#  define BIO_PRI64 "ll"
 # endif
 
 # if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO)


More information about the openssl-commits mailing list