]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Cast values to match printf format strings.
authorJ.W. Jagersma <jwjagersma@gmail.com>
Sat, 1 Oct 2022 16:41:44 +0000 (18:41 +0200)
committerHugo Landau <hlandau@openssl.org>
Mon, 14 Nov 2022 07:47:53 +0000 (07:47 +0000)
For some reason djgpp uses '(unsigned) long int' for (u)int32_t.  This
causes errors with -Werror=format, even though these types are in
practice identical.

Obvious solution: cast to the types indicated by the format string.

For asn1_time_test.c I changed the format string to %lli since time_t
may be 'long long' some platforms.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19322)

crypto/asn1/x_int64.c
ssl/ssl_ciph.c
ssl/ssl_txt.c
ssl/t1_trce.c
test/asn1_time_test.c
test/ssl_cert_table_internal_test.c

index d05fe26bb0a9fefea549eaf5f73a43acd8a86b70..b7251b8ad8b640c84fe0e790613a7e2b0084fb96 100644 (file)
@@ -220,8 +220,8 @@ static int uint32_print(BIO *out, const 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, "%d\n", **(int32_t **)pval);
-    return BIO_printf(out, "%u\n", **(uint32_t **)pval);
+        return BIO_printf(out, "%d\n", (int)**(int32_t **)pval);
+    return BIO_printf(out, "%u\n", (unsigned int)**(uint32_t **)pval);
 }
 
 
index 48aad6342bdfa4ec9a2db57ca258e93c6d96b5ca..8c805fbfcfe365537ddf095f5703308b2010c528 100644 (file)
@@ -820,8 +820,9 @@ static void ssl_cipher_apply_rule(uint32_t cipher_id, uint32_t alg_mkey,
     OSSL_TRACE_BEGIN(TLS_CIPHER) {
         BIO_printf(trc_out,
                    "Applying rule %d with %08x/%08x/%08x/%08x/%08x %08x (%d)\n",
-                   rule, alg_mkey, alg_auth, alg_enc, alg_mac, min_tls,
-                   algo_strength, strength_bits);
+                   rule, (unsigned int)alg_mkey, (unsigned int)alg_auth,
+                   (unsigned int)alg_enc, (unsigned int)alg_mac, min_tls,
+                   (unsigned int)algo_strength, (int)strength_bits);
     }
 
     if (rule == CIPHER_DEL || rule == CIPHER_BUMP)
@@ -865,9 +866,13 @@ static void ssl_cipher_apply_rule(uint32_t cipher_id, uint32_t alg_mkey,
                 BIO_printf(trc_out,
                            "\nName: %s:"
                            "\nAlgo = %08x/%08x/%08x/%08x/%08x Algo_strength = %08x\n",
-                           cp->name, cp->algorithm_mkey, cp->algorithm_auth,
-                           cp->algorithm_enc, cp->algorithm_mac, cp->min_tls,
-                           cp->algo_strength);
+                           cp->name,
+                           (unsigned int)cp->algorithm_mkey,
+                           (unsigned int)cp->algorithm_auth,
+                           (unsigned int)cp->algorithm_enc,
+                           (unsigned int)cp->algorithm_mac,
+                           cp->min_tls,
+                           (unsigned int)cp->algo_strength);
             }
             if (cipher_id != 0 && (cipher_id != cp->id))
                 continue;
index 68f15d6182bfa3ae40c047ba408628fac0259879..9e9c2e10ec8df257aea5153bbaa18c7f12d0114e 100644 (file)
@@ -153,7 +153,7 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)
 
     if (istls13) {
         if (BIO_printf(bp, "    Max Early Data: %u\n",
-                       x->ext.max_early_data) <= 0)
+                       (unsigned int)x->ext.max_early_data) <= 0)
             goto err;
     }
 
index 6d314c5331fa93f73accbac9b87bc35f24618262..fbaa199fd5fa534d97285e09dff9c354b8db180e 100644 (file)
@@ -906,7 +906,7 @@ static int ssl_print_extension(BIO *bio, int indent, int server,
                          | ((unsigned int)ext[2] << 8)
                          | (unsigned int)ext[3];
         BIO_indent(bio, indent + 2, 80);
-        BIO_printf(bio, "max_early_data=%u\n", max_early_data);
+        BIO_printf(bio, "max_early_data=%u\n", (unsigned int)max_early_data);
         break;
 
     default:
index b222b44091a073209734329040dd5e544588b79c..3344b76eae673ce1dbf8afb9aea06ef0b421b52d 100644 (file)
@@ -434,8 +434,10 @@ static int convert_asn1_to_time_t(int idx)
     testdateutc = ossl_asn1_string_to_time_t(asn1_to_utc[idx].input);
 
     if (!TEST_time_t_eq(testdateutc, asn1_to_utc[idx].expected)) {
-        TEST_info("ossl_asn1_string_to_time_t (%s) failed: expected %li, got %li\n",
-                asn1_to_utc[idx].input, asn1_to_utc[idx].expected, (signed long) testdateutc);
+        TEST_info("ossl_asn1_string_to_time_t (%s) failed: expected %lli, got %lli\n",
+                  asn1_to_utc[idx].input,
+                  (long long int)asn1_to_utc[idx].expected,
+                  (long long int)testdateutc);
         return 0;
     }
     return 1;
index 1dc09c013ccfae58bde076ef87c515bd2daf5307..397834a8f1a349e84de7b684ebe0bcc01d8d98d5 100644 (file)
@@ -35,7 +35,8 @@ static int do_test_cert_table(int nid, uint32_t amask, size_t idx,
         TEST_note("Expected %s, got %s\n", OBJ_nid2sn(nid),
                   OBJ_nid2sn(clu->nid));
     if (clu->amask != amask)
-        TEST_note("Expected auth mask 0x%x, got 0x%x\n", amask, clu->amask);
+        TEST_note("Expected auth mask 0x%x, got 0x%x\n",
+                  (unsigned int)amask, (unsigned int)clu->amask);
     return 0;
 }