You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mi...@apache.org on 2018/09/02 20:51:41 UTC

svn commit: r1839895 - in /apr/apr-util/branches/1.7.x: include/apr_jose.h jose/apr_jose_encode.c

Author: minfrin
Date: Sun Sep  2 20:51:41 2018
New Revision: 1839895

URL: http://svn.apache.org/viewvc?rev=1839895&view=rev
Log:
Backport r1839894.

Explicitly declare parameters as nonnull.

Modified:
    apr/apr-util/branches/1.7.x/include/apr_jose.h
    apr/apr-util/branches/1.7.x/jose/apr_jose_encode.c

Modified: apr/apr-util/branches/1.7.x/include/apr_jose.h
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/include/apr_jose.h?rev=1839895&r1=1839894&r2=1839895&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/include/apr_jose.h (original)
+++ apr/apr-util/branches/1.7.x/include/apr_jose.h Sun Sep  2 20:51:41 2018
@@ -914,7 +914,8 @@ typedef struct apr_jose_cb_t {
  * @param jose - context pointer
  * @return The apu_err_t is returned.
  */
-APU_DECLARE(apu_err_t *) apr_jose_error(apr_jose_t *jose);
+APU_DECLARE(apu_err_t *) apr_jose_error(apr_jose_t *jose)
+        __attribute__((nonnull(1)));
 
 /**
  * Make a generic JOSE structure.
@@ -926,7 +927,8 @@ APU_DECLARE(apu_err_t *) apr_jose_error(
  * @return The apr_jose_t is returned.
  */
 APU_DECLARE(apr_jose_t *) apr_jose_make(apr_jose_t *jose, apr_jose_type_e type,
-        apr_pool_t *pool);
+        apr_pool_t *pool)
+        __attribute__((nonnull(3)));
 
 /**
  * Make a JSON Web Key for encoding or decoding.
@@ -938,7 +940,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_make(
  * @return The apr_jose_t is returned.
  */
 APU_DECLARE(apr_jose_t *) apr_jose_jwk_make(apr_jose_t *jose,
-        apr_json_value_t *key, apr_pool_t *pool);
+        apr_json_value_t *key, apr_pool_t *pool)
+        __attribute__((nonnull(3)));
 
 /**
  * Make a JSON Web Key Set.
@@ -950,7 +953,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_jwk_m
  * @return The apr_jose_t is returned.
  */
 APU_DECLARE(apr_jose_t *) apr_jose_jwks_make(apr_jose_t *jose,
-        apr_json_value_t *keys, apr_pool_t *pool);
+        apr_json_value_t *keys, apr_pool_t *pool)
+        __attribute__((nonnull(3)));
 
 /**
  * Make a signature structure for JWS.
@@ -963,7 +967,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_jwks_
  */
 APU_DECLARE(apr_jose_signature_t *) apr_jose_signature_make(
         apr_jose_signature_t *signature, apr_json_value_t *header,
-        apr_json_value_t *protected, apr_pool_t *pool);
+        apr_json_value_t *protected, apr_pool_t *pool)
+        __attribute__((nonnull(4)));
 
 /**
  * Make a recipient structure for JWE.
@@ -974,7 +979,8 @@ APU_DECLARE(apr_jose_signature_t *) apr_
  * @return The apr_jose_recipient_t is returned.
  */
 APU_DECLARE(apr_jose_recipient_t *) apr_jose_recipient_make(apr_jose_recipient_t *recipient,
-        apr_json_value_t *unprotected, apr_pool_t *pool);
+        apr_json_value_t *unprotected, apr_pool_t *pool)
+        __attribute__((nonnull(3)));
 
 /**
  * Make an encryption structure for JWE.
@@ -987,7 +993,8 @@ APU_DECLARE(apr_jose_recipient_t *) apr_
  */
 APU_DECLARE(apr_jose_encryption_t *) apr_jose_encryption_make(apr_jose_encryption_t *encryption,
         apr_json_value_t *unprotected, apr_json_value_t *protected,
-        apr_pool_t *pool);
+        apr_pool_t *pool)
+        __attribute__((nonnull(4)));
 
 /**
  * Make a compact encoded JWE.
@@ -1004,7 +1011,8 @@ APU_DECLARE(apr_jose_encryption_t *) apr
 APU_DECLARE(apr_jose_t *) apr_jose_jwe_make(apr_jose_t *jose,
         apr_jose_recipient_t *recipient, apr_array_header_t *recipients,
         apr_jose_encryption_t *encryption, apr_jose_t *payload,
-        apr_pool_t *pool);
+        apr_pool_t *pool)
+        __attribute__((nonnull(6)));
 
 /**
  * Make a JSON encoded JWE.
@@ -1021,7 +1029,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_jwe_m
 APU_DECLARE(apr_jose_t *) apr_jose_jwe_json_make(apr_jose_t *jose,
         apr_jose_recipient_t *recipient,
         apr_array_header_t *recipients, apr_jose_encryption_t *encryption,
-        apr_jose_t *payload, apr_pool_t *pool);
+        apr_jose_t *payload, apr_pool_t *pool)
+        __attribute__((nonnull(6)));
 
 /**
  * Make a compact encoded JWS.
@@ -1036,7 +1045,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_jwe_j
  */
 APU_DECLARE(apr_jose_t *) apr_jose_jws_make(apr_jose_t *jose,
         apr_jose_signature_t *signature, apr_array_header_t *signatures,
-        apr_jose_t *payload, apr_pool_t *pool);
+        apr_jose_t *payload, apr_pool_t *pool)
+        __attribute__((nonnull(5)));
 
 /**
  * Make a JSON encoded JWS.
@@ -1051,7 +1061,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_jws_m
  */
 APU_DECLARE(apr_jose_t *) apr_jose_jws_json_make(apr_jose_t *jose,
         apr_jose_signature_t *signature, apr_array_header_t *signatures,
-        apr_jose_t *payload, apr_pool_t *pool);
+        apr_jose_t *payload, apr_pool_t *pool)
+        __attribute__((nonnull(5)));
 
 /**
  * Make a JWT claims payload.
@@ -1066,7 +1077,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_jws_j
  * @return The apr_jose_t is returned.
  */
 APU_DECLARE(apr_jose_t *) apr_jose_jwt_make(apr_jose_t *jose,
-        apr_json_value_t *claims, apr_pool_t *pool);
+        apr_json_value_t *claims, apr_pool_t *pool)
+        __attribute__((nonnull(3)));
 
 /**
  * Make a data buffer for encoding from the given data and length.
@@ -1080,7 +1092,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_jwt_m
  * @return The apr_jose_t is returned.
  */
 APU_DECLARE(apr_jose_t *) apr_jose_data_make(apr_jose_t *jose, const char *typ,
-        const unsigned char *in, apr_size_t inlen, apr_pool_t *pool);
+        const unsigned char *in, apr_size_t inlen, apr_pool_t *pool)
+        __attribute__((nonnull(5)));
 
 /**
  * Make a UTF-8 text buffer for encoding from the given string
@@ -1095,7 +1108,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_data_
  * @return The apr_jose_t is returned.
  */
 APU_DECLARE(apr_jose_t *) apr_jose_text_make(apr_jose_t *jose, const char *cty,
-        const char *in, apr_size_t inlen, apr_pool_t *pool);
+        const char *in, apr_size_t inlen, apr_pool_t *pool)
+        __attribute__((nonnull(5)));
 
 /**
  * Make a json structure for encoding.
@@ -1108,7 +1122,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_text_
  * @return The apr_jose_t is returned.
  */
 APU_DECLARE(apr_jose_t *) apr_jose_json_make(apr_jose_t *jose, const char *cty,
-        apr_json_value_t *json, apr_pool_t *pool);
+        apr_json_value_t *json, apr_pool_t *pool)
+        __attribute__((nonnull(4)));
 
 /**
  * Sign or encrypt the apr_jose_t, and write it to the brigade.
@@ -1124,7 +1139,8 @@ APU_DECLARE(apr_jose_t *) apr_jose_json_
  */
 APU_DECLARE(apr_status_t) apr_jose_encode(apr_bucket_brigade *brigade,
         apr_brigade_flush flush, void *ctx, apr_jose_t *jose,
-        apr_jose_cb_t *cb, apr_pool_t *pool);
+        apr_jose_cb_t *cb, apr_pool_t *pool)
+		__attribute__((nonnull(1, 4, 6)));
 
 /**
  * Decode, decrypt and verify the utf8-encoded JOSE string into apr_jose_t.
@@ -1143,7 +1159,8 @@ APU_DECLARE(apr_status_t) apr_jose_encod
  */
 APU_DECLARE(apr_status_t) apr_jose_decode(apr_jose_t **jose, const char *typ,
         apr_bucket_brigade *brigade, apr_jose_cb_t *cb, int level, int flags,
-        apr_pool_t *pool);
+        apr_pool_t *pool)
+        __attribute__((nonnull(1, 3, 7)));
 
 
 #ifdef __cplusplus

Modified: apr/apr-util/branches/1.7.x/jose/apr_jose_encode.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/jose/apr_jose_encode.c?rev=1839895&r1=1839894&r2=1839895&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/jose/apr_jose_encode.c (original)
+++ apr/apr-util/branches/1.7.x/jose/apr_jose_encode.c Sun Sep  2 20:51:41 2018
@@ -678,11 +678,6 @@ apr_status_t apr_jose_encode(apr_bucket_
     apr_pool_t *p;
     apr_status_t status = APR_EINVAL;
 
-    /* if asked to encode nothing, encode nothing */
-    if (jose == NULL) {
-        return APR_SUCCESS;
-    }
-
     apr_pool_create(&p, pool);
     if (p == NULL) {
         return APR_ENOMEM;