Ignore unused return values from some sk_*() macros
authorMatt Caswell <matt@openssl.org>
Thu, 10 Sep 2020 15:34:17 +0000 (16:34 +0100)
committerMatt Caswell <matt@openssl.org>
Sun, 13 Sep 2020 10:11:57 +0000 (11:11 +0100)
Some compilers are very picky about unused return values.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12781)

crypto/ex_data.c
crypto/property/property.c
crypto/x509/v3_addr.c
crypto/x509/x509_vfy.c
crypto/x509/x_name.c
ssl/ssl_ciph.c
test/stack_test.c

index cc9ebc36f46c8ad53a99b2eaab3a4be4225b3b38..c1467a51dc649b75907fc719d9d95d2227634527 100644 (file)
@@ -445,7 +445,11 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
             return 0;
         }
     }
-    sk_void_set(ad->sk, idx, val);
+    if (sk_void_set(ad->sk, idx, val) != val) {
+        /* Probably the index is out of bounds */
+        CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_PASSED_INVALID_ARGUMENT);
+        return 0;
+    }
     return 1;
 }
 
index 608a909d49c2f3980bfade30b5755b640a863e90..c2238ac63d0e9d6c9564999bd817e2cf18de65f5 100644 (file)
@@ -316,7 +316,7 @@ int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid,
 
         if (impl->method.method == method) {
             impl_free(impl);
-            sk_IMPLEMENTATION_delete(alg->impls, i);
+            (void)sk_IMPLEMENTATION_delete(alg->impls, i);
             ossl_property_unlock(store);
             return 1;
         }
index 64127cff6ba7879696f1ace7217fdbf49539d614..7d4e99be5af2e6bbef4e97fbc9de791f220fee9c 100644 (file)
@@ -1257,7 +1257,7 @@ static int addr_validate_path_internal(X509_STORE_CTX *ctx,
                     || addr_contains(fp->ipAddressChoice->u.addressesOrRanges,
                                      fc->ipAddressChoice->u.addressesOrRanges,
                                      length_from_afi(X509v3_addr_get_afi(fc))))
-                    sk_IPAddressFamily_set(child, j, fp);
+                    (void)sk_IPAddressFamily_set(child, j, fp);
                 else
                     validation_err(X509_V_ERR_UNNESTED_RESOURCE);
             }
index d4a085ddb068fe3d5f9d1b1feddde788763e2dec..5520f08e287b656b6f0b0d869e77e811232ff5e0 100644 (file)
@@ -1683,7 +1683,7 @@ static int check_policy(X509_STORE_CTX *ctx)
     ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain,
                             ctx->param->policies, ctx->param->flags);
     if (ctx->bare_ta_signed)
-        sk_X509_pop(ctx->chain);
+        (void)sk_X509_pop(ctx->chain);
 
     if (ret == X509_PCY_TREE_INTERNAL) {
         X509err(X509_F_CHECK_POLICY, ERR_R_MALLOC_FAILURE);
index 692bd6566a2648293f5b041293b02a563c6f552c..a85b10f1cf69856d9a27010a949db55cde206e4e 100644 (file)
@@ -186,7 +186,7 @@ static int x509_name_ex_d2i(ASN1_VALUE **val,
             entry->set = i;
             if (!sk_X509_NAME_ENTRY_push(nm.x->entries, entry))
                 goto err;
-            sk_X509_NAME_ENTRY_set(entries, j, NULL);
+            (void)sk_X509_NAME_ENTRY_set(entries, j, NULL);
         }
     }
     ret = x509_name_canon(nm.x);
index 05add36d4772d73ac36de775c043159661e6b20f..b8d22a72cee9a03740fabca9e232100f0a56bb51 100644 (file)
@@ -1379,7 +1379,7 @@ static int update_cipher_list(STACK_OF(SSL_CIPHER) **cipher_list,
     while (sk_SSL_CIPHER_num(tmp_cipher_list) > 0
            && sk_SSL_CIPHER_value(tmp_cipher_list, 0)->min_tls
               == TLS1_3_VERSION)
-        sk_SSL_CIPHER_delete(tmp_cipher_list, 0);
+        (void)sk_SSL_CIPHER_delete(tmp_cipher_list, 0);
 
     /* Insert the new TLSv1.3 ciphersuites */
     for (i = 0; i < sk_SSL_CIPHER_num(tls13_ciphersuites); i++)
index 1f4cb1cafad2082c92c377b8eea63768f13dc1f7..3aa0b08a436c36760f74d1159839981b0207df58 100644 (file)
@@ -131,7 +131,7 @@ static int test_int_stack(int reserve)
     /* sorting */
     if (!TEST_false(sk_sint_is_sorted(s)))
         goto end;
-    sk_sint_set_cmp_func(s, &int_compare);
+    (void)sk_sint_set_cmp_func(s, &int_compare);
     sk_sint_sort(s);
     if (!TEST_true(sk_sint_is_sorted(s)))
         goto end;
@@ -237,7 +237,7 @@ static int test_uchar_stack(int reserve)
         goto end;
 
     /* set */
-    sk_uchar_set(r, 1, v + 1);
+    (void)sk_uchar_set(r, 1, v + 1);
     for (i = 0; i < 2; i++)
         if (!TEST_ptr_eq(sk_uchar_value(r, i), v + i)) {
             TEST_info("uchar set %d", i);