]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Few nit's
authorFdaSilvaYY <fdasilvayy@gmail.com>
Sat, 24 Sep 2016 11:37:16 +0000 (13:37 +0200)
committerMatt Caswell <matt@openssl.org>
Wed, 25 Jan 2017 09:06:34 +0000 (09:06 +0000)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1618)

crypto/x509/x509_att.c
crypto/x509/x509name.c
crypto/x509v3/v3_alt.c
crypto/x509v3/v3_ncons.c
crypto/x509v3/v3_utl.c
doc/man3/EVP_DigestInit.pod
doc/man3/SSL_CTX_set_tlsext_ticket_key_cb.pod

index 15f0e4fc87e2537f04a1e5fc199d895cc4d1a20a..a91f9829b5629752422e23928c2921ff79eecb42 100644 (file)
@@ -56,8 +56,8 @@ X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc)
 {
     if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
         return NULL;
-    else
-        return sk_X509_ATTRIBUTE_value(x, loc);
+
+    return sk_X509_ATTRIBUTE_value(x, loc);
 }
 
 X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc)
index 919d8c1e7ff95c66f477dc0cf6a645957b0c8d64..ab53794741cd7304a6cccbc4c78b54ff133a8520 100644 (file)
@@ -86,9 +86,9 @@ X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc)
 {
     if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
         || loc < 0)
-        return (NULL);
-    else
-        return (sk_X509_NAME_ENTRY_value(name->entries, loc));
+        return NULL;
+
+    return sk_X509_NAME_ENTRY_value(name->entries, loc);
 }
 
 X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc)
@@ -99,13 +99,14 @@ X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc)
 
     if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
         || loc < 0)
-        return (NULL);
+        return NULL;
+
     sk = name->entries;
     ret = sk_X509_NAME_ENTRY_delete(sk, loc);
     n = sk_X509_NAME_ENTRY_num(sk);
     name->modified = 1;
     if (loc == n)
-        return (ret);
+        return ret;
 
     /* else we need to fixup the set field */
     if (loc != 0)
@@ -127,7 +128,7 @@ X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc)
     if (set_prev + 1 < set_next)
         for (i = loc; i < n; i++)
             sk_X509_NAME_ENTRY_value(sk, i)->set--;
-    return (ret);
+    return ret;
 }
 
 int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
@@ -136,6 +137,7 @@ int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type
 {
     X509_NAME_ENTRY *ne;
     int ret;
+
     ne = X509_NAME_ENTRY_create_by_OBJ(NULL, obj, type, bytes, len);
     if (!ne)
         return 0;
index 0364e336a0d9db16b94aa915959e779382e0e362..3062250d17508b7c79c32ab8820e4776915fbcaf 100644 (file)
@@ -303,10 +303,12 @@ static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p)
     ASN1_IA5STRING *email = NULL;
     X509_NAME_ENTRY *ne;
     GENERAL_NAME *gen = NULL;
-    int i;
+    int i = -1;
+
     if (ctx != NULL && ctx->flags == CTX_TEST)
         return 1;
-    if (!ctx || (!ctx->subject_cert && !ctx->subject_req)) {
+    if (ctx == NULL 
+        || (ctx->subject_cert == NULL && ctx->subject_req == NULL)) {
         X509V3err(X509V3_F_COPY_EMAIL, X509V3_R_NO_SUBJECT_DETAILS);
         goto err;
     }
@@ -317,7 +319,6 @@ static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p)
         nm = X509_REQ_get_subject_name(ctx->subject_req);
 
     /* Now add any email address(es) to STACK */
-    i = -1;
     while ((i = X509_NAME_get_index_by_NID(nm,
                                            NID_pkcs9_emailAddress, i)) >= 0) {
         ne = X509_NAME_get_entry(nm, i);
index 9b3bb128eba26a805417a496c4095b6509190148..36ff966a36bb4de61c5b52f48846b8b4bb84d6d8 100644 (file)
@@ -247,6 +247,7 @@ int NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc)
     for (i = -1;;) {
         X509_NAME_ENTRY *ne;
         ASN1_STRING *hn;
+
         i = X509_NAME_get_index_by_NID(nm, NID_commonName, i);
         if (i == -1)
             break;
index 7dc9a4533efa26a7decc4b3dd3539382fccdf2b2..ac5217053a5aa14ea7425cb4b301aa00efa0d2ea 100644 (file)
@@ -424,11 +424,11 @@ static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name,
 {
     STACK_OF(OPENSSL_STRING) *ret = NULL;
     X509_NAME_ENTRY *ne;
-    ASN1_IA5STRING *email;
+    const ASN1_IA5STRING *email;
     GENERAL_NAME *gen;
-    int i;
+    int i = -1;
+
     /* Now add any email address(es) to STACK */
-    i = -1;
     /* First supplied X509_NAME */
     while ((i = X509_NAME_get_index_by_NID(name,
                                            NID_pkcs9_emailAddress, i)) >= 0) {
index d57f09daadf1f18beeffdcd16b34cf51ede056ed..7d283fa7d30201f85d56fa8aa7be058920f7b134 100644 (file)
@@ -210,7 +210,7 @@ digest name passed on the command line.
  unsigned char md_value[EVP_MAX_MD_SIZE];
  int md_len, i;
 
- if (!argv[1]) {
+ if (argv[1] == NULL) {
         printf("Usage: mdtest digestname\n");
         exit(1);
  }
index 71f879227535a0701fdf31abecc452518dfe22b7..0a925ce03a5d9debd8412092a7e03b39e52a3910 100644 (file)
@@ -130,20 +130,18 @@ Reference Implementation:
   static int ssl_tlsext_ticket_key_cb(SSL *s, unsigned char key_name[16], unsigned char *iv, EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc)
   {
       if (enc) { /* create new session */
-          if (RAND_bytes(iv, EVP_MAX_IV_LENGTH) ) {
+          if (RAND_bytes(iv, EVP_MAX_IV_LENGTH) )
               return -1; /* insufficient random */
-          }
 
           key = currentkey(); /* something that you need to implement */
-          if ( !key ) {
+          if ( key == NULL ) {
               /* current key doesn't exist or isn't valid */
-              key = createkey(); /* something that you need to implement.
+              key = createkey();  /* something that you need to implement.
                                    * createkey needs to initialise, a name,
                                    * an aes_key, a hmac_key and optionally
                                    * an expire time. */
-              if ( !key ) { /* key couldn't be created */
+              if ( key == NULL )  /* key couldn't be created */
                   return 0;
-              }
           }
           memcpy(key_name, key->name, 16);
 
@@ -155,9 +153,8 @@ Reference Implementation:
       } else { /* retrieve session */
           key = findkey(name);
 
-          if (!key || key->expire < now() ) {
+          if (key == NULL || key->expire < now() )
               return 0;
-          }
 
           HMAC_Init_ex(&hctx, key->hmac_key, 16, EVP_sha256(), NULL);
           EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key->aes_key, iv );