X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=apps%2Frehash.c;h=e3c02448fbdd52ca3ee7337e79481a6f5ca76e21;hb=14e353506a8a255c31b5b6b7520e00ed323d5a13;hp=23dbfd8daa41760847b76743332abcefd145b175;hpb=2ac915f16218982f48dbc799b8308a07441d2e35;p=openssl.git diff --git a/apps/rehash.c b/apps/rehash.c index 23dbfd8daa..e3c02448fb 100644 --- a/apps/rehash.c +++ b/apps/rehash.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -254,11 +254,11 @@ static int do_file(const char *filename, const char *fullpath, enum Hash h) goto end; } x = sk_X509_INFO_value(inf, 0); - if (x->x509) { + if (x->x509 != NULL) { type = TYPE_CERT; name = X509_get_subject_name(x->x509); X509_digest(x->x509, evpmd, digest, NULL); - } else if (x->crl) { + } else if (x->crl != NULL) { type = TYPE_CRL; name = X509_CRL_get_issuer(x->crl); X509_CRL_digest(x->crl, evpmd, digest, NULL); @@ -266,7 +266,7 @@ static int do_file(const char *filename, const char *fullpath, enum Hash h) ++errs; goto end; } - if (name) { + if (name != NULL) { if ((h == HASH_NEW) || (h == HASH_BOTH)) errs += add_entry(type, X509_NAME_hash(name), filename, digest, 1, ~0); if ((h == HASH_OLD) || (h == HASH_BOTH)) @@ -287,10 +287,10 @@ static int ends_with_dirsep(const char *path) { if (*path != '\0') path += strlen(path) - 1; -# ifdef __VMS +# if defined __VMS if (*path == ']' || *path == '>' || *path == ':') return 1; -# elif _WIN32 +# elif defined _WIN32 if (*path == '\\') return 1; # endif @@ -362,8 +362,8 @@ static int do_dir(const char *dirname, enum Hash h) numfiles = sk_OPENSSL_STRING_num(files); for (n = 0; n < numfiles; ++n) { filename = sk_OPENSSL_STRING_value(files, n); - if (snprintf(buf, buflen, "%s%s%s", - dirname, pathsep, filename) >= buflen) + if (BIO_snprintf(buf, buflen, "%s%s%s", + dirname, pathsep, filename) >= buflen) continue; if (lstat(buf, &st) < 0) continue; @@ -386,8 +386,8 @@ static int do_dir(const char *dirname, enum Hash h) nextep = ep->next; if (ep->old_id < bp->num_needed) { /* Link exists, and is used as-is */ - snprintf(buf, buflen, "%08x.%s%d", bp->hash, - suffixes[bp->type], ep->old_id); + BIO_snprintf(buf, buflen, "%08x.%s%d", bp->hash, + suffixes[bp->type], ep->old_id); if (verbose) BIO_printf(bio_out, "link %s -> %s\n", ep->filename, buf); @@ -396,9 +396,9 @@ static int do_dir(const char *dirname, enum Hash h) while (bit_isset(idmask, nextid)) nextid++; - snprintf(buf, buflen, "%s%s%n%08x.%s%d", - dirname, pathsep, &n, bp->hash, - suffixes[bp->type], nextid); + BIO_snprintf(buf, buflen, "%s%s%n%08x.%s%d", + dirname, pathsep, &n, bp->hash, + suffixes[bp->type], nextid); if (verbose) BIO_printf(bio_out, "link %s -> %s\n", ep->filename, &buf[n]); @@ -418,9 +418,9 @@ static int do_dir(const char *dirname, enum Hash h) bit_set(idmask, nextid); } else if (remove_links) { /* Link to be deleted */ - snprintf(buf, buflen, "%s%s%n%08x.%s%d", - dirname, pathsep, &n, bp->hash, - suffixes[bp->type], ep->old_id); + BIO_snprintf(buf, buflen, "%s%s%n%08x.%s%d", + dirname, pathsep, &n, bp->hash, + suffixes[bp->type], ep->old_id); if (verbose) BIO_printf(bio_out, "unlink %s\n", &buf[n]); @@ -499,8 +499,8 @@ int rehash_main(int argc, char **argv) evpmd = EVP_sha1(); evpmdsize = EVP_MD_size(evpmd); - if (*argv) { - while (*argv) + if (*argv != NULL) { + while (*argv != NULL) errs += do_dir(*argv++, h); } else if ((env = getenv("SSL_CERT_DIR")) != NULL) { m = OPENSSL_strdup(env);