From a836f9fa951e33a5186e2421413de0b50ed2233a Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Fri, 8 Dec 2017 15:17:12 -0500 Subject: [PATCH] Standardize syntax of sizeof(foo) Reviewed-by: Andy Polyakov (Merged from https://github.com/openssl/openssl/pull/4876) --- apps/app_rand.c | 4 +- apps/apps.c | 48 +++++++------- apps/ciphers.c | 2 +- apps/dhparam.c | 4 +- apps/dsaparam.c | 6 +- apps/ecparam.c | 12 ++-- apps/enc.c | 22 +++---- apps/errstr.c | 2 +- apps/ocsp.c | 4 +- apps/openssl.c | 2 +- apps/opt.c | 18 ++--- apps/passwd.c | 20 +++--- apps/pkcs12.c | 10 +-- apps/pkcs8.c | 4 +- apps/rand.c | 2 +- apps/req.c | 36 +++++----- apps/s_client.c | 8 +-- apps/s_server.c | 10 +-- apps/s_time.c | 6 +- apps/speed.c | 10 +-- apps/vms_term_sock.c | 12 ++-- apps/x509.c | 4 +- crypto/asn1/a_mbstr.c | 4 +- crypto/asn1/a_object.c | 4 +- crypto/asn1/a_strex.c | 8 +-- crypto/asn1/asn1_par.c | 8 +-- crypto/asn1/tasn_prn.c | 2 +- crypto/async/async.c | 6 +- crypto/async/async_wait.c | 2 +- crypto/bio/b_addr.c | 2 +- crypto/bio/b_dump.c | 24 +++---- crypto/bio/b_print.c | 4 +- crypto/bio/bio_cb.c | 2 +- crypto/bio/bss_file.c | 10 +-- crypto/bn/bn_print.c | 4 +- crypto/conf/conf_def.c | 2 +- crypto/conf/conf_mod.c | 2 +- crypto/des/ecb_enc.c | 2 +- crypto/des/fcrypt.c | 2 +- crypto/des/set_key.c | 2 +- crypto/ec/ec_mult.c | 12 ++-- crypto/ec/ecp_nistp224.c | 6 +- crypto/ec/ecp_nistp256.c | 6 +- crypto/ec/ecp_nistp521.c | 6 +- crypto/ec/ecp_smpl.c | 2 +- crypto/err/err_prn.c | 2 +- crypto/evp/evp_enc.c | 6 +- crypto/evp/evp_pbe.c | 4 +- crypto/evp/p5_crpt2.c | 2 +- crypto/init.c | 2 +- crypto/mem_dbg.c | 8 +-- crypto/mem_sec.c | 6 +- crypto/objects/obj_dat.c | 2 +- crypto/pem/pem_info.c | 2 +- crypto/pem/pem_lib.c | 2 +- crypto/rand/md_rand.c | 10 +-- crypto/rand/rand_egd.c | 2 +- crypto/rand/rand_unix.c | 10 +-- crypto/rsa/rsa_pss.c | 4 +- crypto/x509/t_x509.c | 4 +- crypto/x509v3/v3_alt.c | 4 +- crypto/x509v3/v3_info.c | 2 +- ssl/record/rec_layer_d1.c | 4 +- ssl/record/rec_layer_s3.c | 8 +-- ssl/s3_lib.c | 2 +- ssl/ssl_cert.c | 6 +- ssl/ssl_lib.c | 6 +- ssl/ssl_sess.c | 6 +- ssl/statem/statem_clnt.c | 2 +- test/bftest.c | 2 +- test/bntest.c | 2 +- test/d2i_test.c | 2 +- test/dhtest.c | 2 +- test/dsatest.c | 2 +- test/ectest.c | 14 ++-- test/exptest.c | 8 ++- test/igetest.c | 134 +++++++++++++++++++------------------- test/rsa_test.c | 2 +- test/sanitytest.c | 2 +- test/ssltest_old.c | 24 +++---- 80 files changed, 335 insertions(+), 333 deletions(-) diff --git a/apps/app_rand.c b/apps/app_rand.c index 0d44af903b..ff0771cb7a 100644 --- a/apps/app_rand.c +++ b/apps/app_rand.c @@ -20,7 +20,7 @@ int app_RAND_load_file(const char *file, int dont_warn) char buffer[200]; if (file == NULL) - file = RAND_file_name(buffer, sizeof buffer); + file = RAND_file_name(buffer, sizeof(buffer)); #ifndef OPENSSL_NO_EGD else if (RAND_egd(file) > 0) { /* @@ -101,7 +101,7 @@ int app_RAND_write_file(const char *file) return 0; if (file == NULL) - file = RAND_file_name(buffer, sizeof buffer); + file = RAND_file_name(buffer, sizeof(buffer)); if (file == NULL || !RAND_write_file(file)) { BIO_printf(bio_err, "unable to write 'random state'\n"); return 0; diff --git a/apps/apps.c b/apps/apps.c index d93b83bfdd..8703d0cc31 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -1388,9 +1388,9 @@ int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial OPENSSL_strlcpy(buf[0], serialfile, BSIZE); else { #ifndef OPENSSL_SYS_VMS - j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", serialfile, suffix); #else - j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", serialfile, suffix); #endif } out = BIO_new_file(buf[0], "w"); @@ -1431,11 +1431,11 @@ int rotate_serial(const char *serialfile, const char *new_suffix, goto err; } #ifndef OPENSSL_SYS_VMS - j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, new_suffix); - j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", serialfile, old_suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", serialfile, new_suffix); + j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", serialfile, old_suffix); #else - j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, new_suffix); - j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", serialfile, old_suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", serialfile, new_suffix); + j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", serialfile, old_suffix); #endif if (rename(serialfile, buf[1]) < 0 && errno != ENOENT #ifdef ENOTDIR @@ -1504,9 +1504,9 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr) goto err; #ifndef OPENSSL_SYS_VMS - BIO_snprintf(buf, sizeof buf, "%s.attr", dbfile); + BIO_snprintf(buf, sizeof(buf), "%s.attr", dbfile); #else - BIO_snprintf(buf, sizeof buf, "%s-attr", dbfile); + BIO_snprintf(buf, sizeof(buf), "%s-attr", dbfile); #endif dbattr_conf = app_load_config(buf); @@ -1567,13 +1567,13 @@ int save_index(const char *dbfile, const char *suffix, CA_DB *db) goto err; } #ifndef OPENSSL_SYS_VMS - j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr", dbfile); - j = BIO_snprintf(buf[1], sizeof buf[1], "%s.attr.%s", dbfile, suffix); - j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, suffix); + j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s.attr", dbfile); + j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.attr.%s", dbfile, suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, suffix); #else - j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr", dbfile); - j = BIO_snprintf(buf[1], sizeof buf[1], "%s-attr-%s", dbfile, suffix); - j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, suffix); + j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr", dbfile); + j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-attr-%s", dbfile, suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, suffix); #endif out = BIO_new_file(buf[0], "w"); if (out == NULL) { @@ -1616,17 +1616,17 @@ int rotate_index(const char *dbfile, const char *new_suffix, goto err; } #ifndef OPENSSL_SYS_VMS - j = BIO_snprintf(buf[4], sizeof buf[4], "%s.attr", dbfile); - j = BIO_snprintf(buf[3], sizeof buf[3], "%s.attr.%s", dbfile, old_suffix); - j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr.%s", dbfile, new_suffix); - j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", dbfile, old_suffix); - j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, new_suffix); + j = BIO_snprintf(buf[4], sizeof(buf[4]), "%s.attr", dbfile); + j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s.attr.%s", dbfile, old_suffix); + j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s.attr.%s", dbfile, new_suffix); + j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", dbfile, old_suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, new_suffix); #else - j = BIO_snprintf(buf[4], sizeof buf[4], "%s-attr", dbfile); - j = BIO_snprintf(buf[3], sizeof buf[3], "%s-attr-%s", dbfile, old_suffix); - j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr-%s", dbfile, new_suffix); - j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", dbfile, old_suffix); - j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, new_suffix); + j = BIO_snprintf(buf[4], sizeof(buf[4]), "%s-attr", dbfile); + j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s-attr-%s", dbfile, old_suffix); + j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr-%s", dbfile, new_suffix); + j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", dbfile, old_suffix); + j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, new_suffix); #endif if (rename(dbfile, buf[1]) < 0 && errno != ENOENT #ifdef ENOTDIR diff --git a/apps/ciphers.c b/apps/ciphers.c index c0f43ea2e8..e1b5b255c9 100644 --- a/apps/ciphers.c +++ b/apps/ciphers.c @@ -225,7 +225,7 @@ int ciphers_main(int argc, char **argv) BIO_printf(bio_out, "%s - ", nm); } #endif - BIO_puts(bio_out, SSL_CIPHER_description(c, buf, sizeof buf)); + BIO_puts(bio_out, SSL_CIPHER_description(c, buf, sizeof(buf))); } } diff --git a/apps/dhparam.c b/apps/dhparam.c index 0616333af4..94322e37de 100644 --- a/apps/dhparam.c +++ b/apps/dhparam.c @@ -326,9 +326,9 @@ int dhparam_main(int argc, char **argv) "\n" " if (dh == NULL)\n" " return NULL;\n"); - BIO_printf(out, " dhp_bn = BN_bin2bn(dhp_%d, sizeof (dhp_%d), NULL);\n", + BIO_printf(out, " dhp_bn = BN_bin2bn(dhp_%d, sizeof(dhp_%d), NULL);\n", bits, bits); - BIO_printf(out, " dhg_bn = BN_bin2bn(dhg_%d, sizeof (dhg_%d), NULL);\n", + BIO_printf(out, " dhg_bn = BN_bin2bn(dhg_%d, sizeof(dhg_%d), NULL);\n", bits, bits); BIO_printf(out, " if (dhp_bn == NULL || dhg_bn == NULL\n" " || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn)) {\n" diff --git a/apps/dsaparam.c b/apps/dsaparam.c index 925880300f..dd69461b21 100644 --- a/apps/dsaparam.c +++ b/apps/dsaparam.c @@ -234,11 +234,11 @@ int dsaparam_main(int argc, char **argv) "\n"); BIO_printf(bio_out, " if (dsa == NULL)\n" " return NULL;\n"); - BIO_printf(bio_out, " dsa->p = BN_bin2bn(dsap_%d, sizeof (dsap_%d), NULL);\n", + BIO_printf(bio_out, " dsa->p = BN_bin2bn(dsap_%d, sizeof(dsap_%d), NULL);\n", bits_p, bits_p); - BIO_printf(bio_out, " dsa->q = BN_bin2bn(dsaq_%d, sizeof (dsaq_%d), NULL);\n", + BIO_printf(bio_out, " dsa->q = BN_bin2bn(dsaq_%d, sizeof(dsaq_%d), NULL);\n", bits_p, bits_p); - BIO_printf(bio_out, " dsa->g = BN_bin2bn(dsag_%d, sizeof (dsag_%d), NULL);\n", + BIO_printf(bio_out, " dsa->g = BN_bin2bn(dsag_%d, sizeof(dsag_%d), NULL);\n", bits_p, bits_p); BIO_printf(bio_out, " if (!dsa->p || !dsa->q || !dsa->g) {\n" " DSA_free(dsa);\n" diff --git a/apps/ecparam.c b/apps/ecparam.c index 891a0cac0c..086bbebd3e 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -357,24 +357,24 @@ int ecparam_main(int argc, char **argv) " BIGNUM *tmp_3 = NULL;\n" "\n"); - BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_p_%d, sizeof (ec_p_%d), NULL)) == NULL)\n" + BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_p_%d, sizeof(ec_p_%d), NULL)) == NULL)\n" " goto err;\n", len, len); - BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_a_%d, sizeof (ec_a_%d), NULL)) == NULL)\n" + BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_a_%d, sizeof(ec_a_%d), NULL)) == NULL)\n" " goto err;\n", len, len); - BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_b_%d, sizeof (ec_b_%d), NULL)) == NULL)\n" + BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_b_%d, sizeof(ec_b_%d), NULL)) == NULL)\n" " goto err;\n", len, len); BIO_printf(out, " if ((group = EC_GROUP_new_curve_GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL)\n" " goto err;\n" "\n"); BIO_printf(out, " /* build generator */\n"); - BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_gen_%d, sizeof (ec_gen_%d), tmp_1)) == NULL)\n" + BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_gen_%d, sizeof(ec_gen_%d), tmp_1)) == NULL)\n" " goto err;\n", len, len); BIO_printf(out, " point = EC_POINT_bn2point(group, tmp_1, NULL, NULL);\n"); BIO_printf(out, " if (point == NULL)\n" " goto err;\n"); - BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_order_%d, sizeof (ec_order_%d), tmp_2)) == NULL)\n" + BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_order_%d, sizeof(ec_order_%d), tmp_2)) == NULL)\n" " goto err;\n", len, len); - BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_cofactor_%d, sizeof (ec_cofactor_%d), tmp_3)) == NULL)\n" + BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_cofactor_%d, sizeof(ec_cofactor_%d), tmp_3)) == NULL)\n" " goto err;\n", len, len); BIO_printf(out, " if (!EC_GROUP_set_generator(group, point, tmp_2, tmp_3))\n" " goto err;\n" diff --git a/apps/enc.c b/apps/enc.c index c906563311..ef65606578 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -96,7 +96,7 @@ int enc_main(int argc, char **argv) char *hkey = NULL, *hiv = NULL, *hsalt = NULL, *p; char *infile = NULL, *outfile = NULL, *prog; char *str = NULL, *passarg = NULL, *pass = NULL, *strbuf = NULL; - char mbuf[sizeof magic - 1]; + char mbuf[sizeof(magic) - 1]; OPTION_CHOICE o; int bsize = BSIZE, verbose = 0, debug = 0, olb64 = 0, nosalt = 0; int enc = 1, printkey = 0, i, k; @@ -218,7 +218,7 @@ int enc_main(int argc, char **argv) in = bio_open_default(opt_arg(), 'r', FORMAT_TEXT); if (in == NULL) goto opthelp; - i = BIO_gets(in, buf, sizeof buf); + i = BIO_gets(in, buf, sizeof(buf)); BIO_free(in); in = NULL; if (i <= 0) { @@ -311,7 +311,7 @@ int enc_main(int argc, char **argv) for (;;) { char prompt[200]; - BIO_snprintf(prompt, sizeof prompt, "enter %s %s password:", + BIO_snprintf(prompt, sizeof(prompt), "enter %s %s password:", OBJ_nid2ln(EVP_CIPHER_nid(cipher)), (enc) ? "encryption" : "decryption"); strbuf[0] = '\0'; @@ -398,31 +398,31 @@ int enc_main(int argc, char **argv) else { if (enc) { if (hsalt) { - if (!set_hex(hsalt, salt, sizeof salt)) { + if (!set_hex(hsalt, salt, sizeof(salt))) { BIO_printf(bio_err, "invalid hex salt value\n"); goto end; } - } else if (RAND_bytes(salt, sizeof salt) <= 0) + } else if (RAND_bytes(salt, sizeof(salt)) <= 0) goto end; /* * If -P option then don't bother writing */ if ((printkey != 2) && (BIO_write(wbio, magic, - sizeof magic - 1) != sizeof magic - 1 + sizeof(magic) - 1) != sizeof(magic) - 1 || BIO_write(wbio, (char *)salt, - sizeof salt) != sizeof salt)) { + sizeof(salt)) != sizeof(salt))) { BIO_printf(bio_err, "error writing output file\n"); goto end; } - } else if (BIO_read(rbio, mbuf, sizeof mbuf) != sizeof mbuf + } else if (BIO_read(rbio, mbuf, sizeof(mbuf)) != sizeof(mbuf) || BIO_read(rbio, (unsigned char *)salt, - sizeof salt) != sizeof salt) { + sizeof(salt)) != sizeof(salt)) { BIO_printf(bio_err, "error reading input file\n"); goto end; - } else if (memcmp(mbuf, magic, sizeof magic - 1)) { + } else if (memcmp(mbuf, magic, sizeof(magic) - 1)) { BIO_printf(bio_err, "bad magic number\n"); goto end; } @@ -449,7 +449,7 @@ int enc_main(int argc, char **argv) int siz = EVP_CIPHER_iv_length(cipher); if (siz == 0) { BIO_printf(bio_err, "warning: iv not use by this cipher\n"); - } else if (!set_hex(hiv, iv, sizeof iv)) { + } else if (!set_hex(hiv, iv, sizeof(iv))) { BIO_printf(bio_err, "invalid hex iv value\n"); goto end; } diff --git a/apps/errstr.c b/apps/errstr.c index 5fda799d14..79d83ee464 100644 --- a/apps/errstr.c +++ b/apps/errstr.c @@ -58,7 +58,7 @@ int errstr_main(int argc, char **argv) */ OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); - ERR_error_string_n(l, buf, sizeof buf); + ERR_error_string_n(l, buf, sizeof(buf)); BIO_printf(bio_out, "%s\n", buf); } } diff --git a/apps/ocsp.c b/apps/ocsp.c index 41ea970307..4b533348b4 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -1074,7 +1074,7 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio) *pcbio = cbio; /* Read the request line. */ - len = BIO_gets(cbio, reqbuf, sizeof reqbuf); + len = BIO_gets(cbio, reqbuf, sizeof(reqbuf)); if (len <= 0) return 1; if (strncmp(reqbuf, "GET ", 4) == 0) { @@ -1116,7 +1116,7 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio) /* Read and skip past the headers. */ for (;;) { - len = BIO_gets(cbio, inbuf, sizeof inbuf); + len = BIO_gets(cbio, inbuf, sizeof(inbuf)); if (len <= 0) return 1; if ((inbuf[0] == '\r') || (inbuf[0] == '\n')) diff --git a/apps/openssl.c b/apps/openssl.c index 6e7b02c64d..31962cd712 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) for (;;) { ret = 0; /* Read a line, continue reading if line ends with \ */ - for (p = buf, n = sizeof buf, i = 0, first = 1; n > 0; first = 0) { + for (p = buf, n = sizeof(buf), i = 0, first = 1; n > 0; first = 0) { prompt = first ? "OpenSSL> " : "> "; p[0] = '\0'; #ifndef READLINE diff --git a/apps/opt.c b/apps/opt.c index 4c3a26e5a7..6e40f6480b 100644 --- a/apps/opt.c +++ b/apps/opt.c @@ -60,8 +60,8 @@ char *opt_progname(const char *argv0) n -= 4; /* Copy over the name, in lowercase. */ - if (n > sizeof prog - 1) - n = sizeof prog - 1; + if (n > sizeof(prog) - 1) + n = sizeof(prog) - 1; for (q = prog, i = 0; i < n; i++, p++) *q++ = tolower((unsigned char)*p); *q = '\0'; @@ -82,9 +82,9 @@ char *opt_progname(const char *argv0) } q = strrchr(p, '.'); - strncpy(prog, p, sizeof prog - 1); - prog[sizeof prog - 1] = '\0'; - if (q != NULL && q - p < sizeof prog) + strncpy(prog, p, sizeof(prog) - 1); + prog[sizeof(prog) - 1] = '\0'; + if (q != NULL && q - p < sizeof(prog)) prog[q - p] = '\0'; return prog; } @@ -101,8 +101,8 @@ char *opt_progname(const char *argv0) p++; break; } - strncpy(prog, p, sizeof prog - 1); - prog[sizeof prog - 1] = '\0'; + strncpy(prog, p, sizeof(prog) - 1); + prog[sizeof(prog) - 1] = '\0'; return prog; } #endif @@ -840,7 +840,7 @@ void opt_help(const OPTIONS *list) i += 1 + strlen(valtype2param(o)); if (i < MAX_OPT_HELP_WIDTH && i > width) width = i; - assert(i < (int)sizeof start); + assert(i < (int)sizeof(start)); } if (standard_prolog) @@ -857,7 +857,7 @@ void opt_help(const OPTIONS *list) /* Pad out prefix */ memset(start, ' ', sizeof(start) - 1); - start[sizeof start - 1] = '\0'; + start[sizeof(start) - 1] = '\0'; if (o->name == OPT_MORE_STR) { /* Continuation of previous line; pad and print. */ diff --git a/apps/passwd.c b/apps/passwd.c index 85577fa4fb..f2b0d9a29d 100644 --- a/apps/passwd.c +++ b/apps/passwd.c @@ -249,7 +249,7 @@ int passwd_main(int argc, char **argv) /* ignore rest of line */ char trash[BUFSIZ]; do - r = BIO_gets(in, trash, sizeof trash); + r = BIO_gets(in, trash, sizeof(trash)); while ((r > 0) && (!strchr(trash, '\n'))); } @@ -300,9 +300,9 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt) if (magic_len > 4) /* assert it's "1" or "apr1" */ return NULL; - OPENSSL_strlcat(out_buf, magic, sizeof out_buf); - OPENSSL_strlcat(out_buf, "$", sizeof out_buf); - OPENSSL_strlcat(out_buf, salt, sizeof out_buf); + OPENSSL_strlcat(out_buf, magic, sizeof(out_buf)); + OPENSSL_strlcat(out_buf, "$", sizeof(out_buf)); + OPENSSL_strlcat(out_buf, salt, sizeof(out_buf)); if (strlen(out_buf) > 6 + 8) /* assert "$apr1$..salt.." */ return NULL; @@ -332,8 +332,8 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt) || !EVP_DigestFinal_ex(md2, buf, NULL)) goto err; - for (i = passwd_len; i > sizeof buf; i -= sizeof buf) { - if (!EVP_DigestUpdate(md, buf, sizeof buf)) + for (i = passwd_len; i > sizeof(buf); i -= sizeof(buf)) { + if (!EVP_DigestUpdate(md, buf, sizeof(buf))) goto err; } if (!EVP_DigestUpdate(md, buf, i)) @@ -353,7 +353,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt) goto err; if (!EVP_DigestUpdate(md2, (i & 1) ? (unsigned const char *)passwd : buf, - (i & 1) ? passwd_len : sizeof buf)) + (i & 1) ? passwd_len : sizeof(buf))) goto err; if (i % 3) { if (!EVP_DigestUpdate(md2, salt_out, salt_len)) @@ -365,7 +365,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt) } if (!EVP_DigestUpdate(md2, (i & 1) ? buf : (unsigned const char *)passwd, - (i & 1) ? sizeof buf : passwd_len)) + (i & 1) ? sizeof(buf) : passwd_len)) goto err; if (!EVP_DigestFinal_ex(md2, buf, NULL)) goto err; @@ -377,7 +377,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt) { /* transform buf into output string */ - unsigned char buf_perm[sizeof buf]; + unsigned char buf_perm[sizeof(buf)]; int dest, source; char *output; @@ -389,7 +389,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt) buf_perm[15] = buf[11]; # ifndef PEDANTIC /* Unfortunately, this generates a "no * effect" warning */ - assert(16 == sizeof buf_perm); + assert(16 == sizeof(buf_perm)); # endif output = salt_out + salt_len; diff --git a/apps/pkcs12.c b/apps/pkcs12.c index 6c07e810bf..85f649d812 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -323,7 +323,7 @@ int pkcs12_main(int argc, char **argv) if (1) { #ifndef OPENSSL_NO_UI if (EVP_read_pw_string - (macpass, sizeof macpass, "Enter MAC Password:", export_cert)) { + (macpass, sizeof(macpass), "Enter MAC Password:", export_cert)) { BIO_printf(bio_err, "Can't read Password\n"); goto end; } @@ -440,7 +440,7 @@ int pkcs12_main(int argc, char **argv) if (!noprompt) { if (1) { #ifndef OPENSSL_NO_UI - if (EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:", + if (EVP_read_pw_string(pass, sizeof(pass), "Enter Export Password:", 1)) { BIO_printf(bio_err, "Can't read Password\n"); goto export_end; @@ -453,7 +453,7 @@ int pkcs12_main(int argc, char **argv) } if (!twopass) - OPENSSL_strlcpy(macpass, pass, sizeof macpass); + OPENSSL_strlcpy(macpass, pass, sizeof(macpass)); p12 = PKCS12_create(cpass, name, key, ucert, certs, key_pbe, cert_pbe, iter, -1, keytype); @@ -506,7 +506,7 @@ int pkcs12_main(int argc, char **argv) if (!noprompt) { if (1) { #ifndef OPENSSL_NO_UI - if (EVP_read_pw_string(pass, sizeof pass, "Enter Import Password:", + if (EVP_read_pw_string(pass, sizeof(pass), "Enter Import Password:", 0)) { BIO_printf(bio_err, "Can't read Password\n"); goto end; @@ -519,7 +519,7 @@ int pkcs12_main(int argc, char **argv) } if (!twopass) - OPENSSL_strlcpy(macpass, pass, sizeof macpass); + OPENSSL_strlcpy(macpass, pass, sizeof(macpass)); if ((options & INFO) && PKCS12_mac_present(p12)) { const ASN1_INTEGER *tmaciter; diff --git a/apps/pkcs8.c b/apps/pkcs8.c index 4b3fa10d23..0874370d0c 100644 --- a/apps/pkcs8.c +++ b/apps/pkcs8.c @@ -238,7 +238,7 @@ int pkcs8_main(int argc, char **argv) #ifndef OPENSSL_NO_UI p8pass = pass; if (EVP_read_pw_string - (pass, sizeof pass, "Enter Encryption Password:", 1)) { + (pass, sizeof(pass), "Enter Encryption Password:", 1)) { X509_ALGOR_free(pbe); goto end; } @@ -300,7 +300,7 @@ int pkcs8_main(int argc, char **argv) else if (1) { #ifndef OPENSSL_NO_UI p8pass = pass; - if (EVP_read_pw_string(pass, sizeof pass, "Enter Password:", 0)) { + if (EVP_read_pw_string(pass, sizeof(pass), "Enter Password:", 0)) { BIO_printf(bio_err, "Can't read Password\n"); goto end; } diff --git a/apps/rand.c b/apps/rand.c index e72618027b..21c9a7ad24 100644 --- a/apps/rand.c +++ b/apps/rand.c @@ -102,7 +102,7 @@ int rand_main(int argc, char **argv) chunk = num; if (chunk > (int)sizeof(buf)) - chunk = sizeof buf; + chunk = sizeof(buf); r = RAND_bytes(buf, chunk); if (r <= 0) goto end; diff --git a/apps/req.c b/apps/req.c index a749925ba0..2a2156953a 100644 --- a/apps/req.c +++ b/apps/req.c @@ -973,7 +973,7 @@ static int prompt_info(X509_REQ *req, /* If OBJ not recognised ignore it */ if ((nid = OBJ_txt2nid(type)) == NID_undef) goto start; - if (BIO_snprintf(buf, sizeof buf, "%s_default", v->name) + if (BIO_snprintf(buf, sizeof(buf), "%s_default", v->name) >= (int)sizeof(buf)) { BIO_printf(bio_err, "Name '%s' too long\n", v->name); return 0; @@ -984,19 +984,19 @@ static int prompt_info(X509_REQ *req, def = ""; } - BIO_snprintf(buf, sizeof buf, "%s_value", v->name); + BIO_snprintf(buf, sizeof(buf), "%s_value", v->name); if ((value = NCONF_get_string(req_conf, dn_sect, buf)) == NULL) { ERR_clear_error(); value = NULL; } - BIO_snprintf(buf, sizeof buf, "%s_min", v->name); + BIO_snprintf(buf, sizeof(buf), "%s_min", v->name); if (!NCONF_get_number(req_conf, dn_sect, buf, &n_min)) { ERR_clear_error(); n_min = -1; } - BIO_snprintf(buf, sizeof buf, "%s_max", v->name); + BIO_snprintf(buf, sizeof(buf), "%s_max", v->name); if (!NCONF_get_number(req_conf, dn_sect, buf, &n_max)) { ERR_clear_error(); n_max = -1; @@ -1032,7 +1032,7 @@ static int prompt_info(X509_REQ *req, if ((nid = OBJ_txt2nid(type)) == NID_undef) goto start2; - if (BIO_snprintf(buf, sizeof buf, "%s_default", type) + if (BIO_snprintf(buf, sizeof(buf), "%s_default", type) >= (int)sizeof(buf)) { BIO_printf(bio_err, "Name '%s' too long\n", v->name); return 0; @@ -1044,20 +1044,20 @@ static int prompt_info(X509_REQ *req, def = ""; } - BIO_snprintf(buf, sizeof buf, "%s_value", type); + BIO_snprintf(buf, sizeof(buf), "%s_value", type); if ((value = NCONF_get_string(req_conf, attr_sect, buf)) == NULL) { ERR_clear_error(); value = NULL; } - BIO_snprintf(buf, sizeof buf, "%s_min", type); + BIO_snprintf(buf, sizeof(buf), "%s_min", type); if (!NCONF_get_number(req_conf, attr_sect, buf, &n_min)) { ERR_clear_error(); n_min = -1; } - BIO_snprintf(buf, sizeof buf, "%s_max", type); + BIO_snprintf(buf, sizeof(buf), "%s_max", type); if (!NCONF_get_number(req_conf, attr_sect, buf, &n_max)) { ERR_clear_error(); n_max = -1; @@ -1155,13 +1155,13 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def, BIO_printf(bio_err, "%s [%s]:", text, def); (void)BIO_flush(bio_err); if (value != NULL) { - OPENSSL_strlcpy(buf, value, sizeof buf); - OPENSSL_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, value, sizeof(buf)); + OPENSSL_strlcat(buf, "\n", sizeof(buf)); BIO_printf(bio_err, "%s\n", value); } else { buf[0] = '\0'; if (!batch) { - if (!fgets(buf, sizeof buf, stdin)) + if (!fgets(buf, sizeof(buf), stdin)) return 0; } else { buf[0] = '\n'; @@ -1174,8 +1174,8 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def, else if (buf[0] == '\n') { if ((def == NULL) || (def[0] == '\0')) return (1); - OPENSSL_strlcpy(buf, def, sizeof buf); - OPENSSL_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, def, sizeof(buf)); + OPENSSL_strlcat(buf, "\n", sizeof(buf)); } else if ((buf[0] == '.') && (buf[1] == '\n')) return (1); @@ -1214,13 +1214,13 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def, BIO_printf(bio_err, "%s [%s]:", text, def); (void)BIO_flush(bio_err); if (value != NULL) { - OPENSSL_strlcpy(buf, value, sizeof buf); - OPENSSL_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, value, sizeof(buf)); + OPENSSL_strlcat(buf, "\n", sizeof(buf)); BIO_printf(bio_err, "%s\n", value); } else { buf[0] = '\0'; if (!batch) { - if (!fgets(buf, sizeof buf, stdin)) + if (!fgets(buf, sizeof(buf), stdin)) return 0; } else { buf[0] = '\n'; @@ -1233,8 +1233,8 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def, else if (buf[0] == '\n') { if ((def == NULL) || (def[0] == '\0')) return (1); - OPENSSL_strlcpy(buf, def, sizeof buf); - OPENSSL_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, def, sizeof(buf)); + OPENSSL_strlcat(buf, "\n", sizeof(buf)); } else if ((buf[0] == '.') && (buf[1] == '\n')) return (1); diff --git a/apps/s_client.c b/apps/s_client.c index 2f1b228a14..fab007a86a 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2536,10 +2536,10 @@ static void print_stuff(BIO *bio, SSL *s, int full) BIO_printf(bio, "---\nCertificate chain\n"); for (i = 0; i < sk_X509_num(sk); i++) { X509_NAME_oneline(X509_get_subject_name(sk_X509_value(sk, i)), - buf, sizeof buf); + buf, sizeof(buf)); BIO_printf(bio, "%2d s:%s\n", i, buf); X509_NAME_oneline(X509_get_issuer_name(sk_X509_value(sk, i)), - buf, sizeof buf); + buf, sizeof(buf)); BIO_printf(bio, " i:%s\n", buf); if (c_showcerts) PEM_write_bio_X509(bio, sk_X509_value(sk, i)); @@ -2554,9 +2554,9 @@ static void print_stuff(BIO *bio, SSL *s, int full) /* Redundant if we showed the whole chain */ if (!(c_showcerts && got_a_chain)) PEM_write_bio_X509(bio, peer); - X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf); + X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof(buf)); BIO_printf(bio, "subject=%s\n", buf); - X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf); + X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof(buf)); BIO_printf(bio, "issuer=%s\n", buf); } else BIO_printf(bio, "no peer certificate available\n"); diff --git a/apps/s_server.c b/apps/s_server.c index f6418af46b..09e608abaf 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -1853,7 +1853,7 @@ int s_server_main(int argc, char *argv[]) SSL_CTX_set_verify(ctx, s_server_verify, verify_callback); if (!SSL_CTX_set_session_id_context(ctx, (void *)&s_server_session_id_context, - sizeof s_server_session_id_context)) { + sizeof(s_server_session_id_context))) { BIO_printf(bio_err, "error setting session id context\n"); ERR_print_errors(bio_err); goto end; @@ -1867,7 +1867,7 @@ int s_server_main(int argc, char *argv[]) SSL_CTX_set_verify(ctx2, s_server_verify, verify_callback); if (!SSL_CTX_set_session_id_context(ctx2, (void *)&s_server_session_id_context, - sizeof s_server_session_id_context)) { + sizeof(s_server_session_id_context))) { BIO_printf(bio_err, "error setting session id context\n"); ERR_print_errors(bio_err); goto end; @@ -2535,15 +2535,15 @@ static int init_ssl_connection(SSL *con) if (peer != NULL) { BIO_printf(bio_s_out, "Client certificate\n"); PEM_write_bio_X509(bio_s_out, peer); - X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf); + X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof(buf)); BIO_printf(bio_s_out, "subject=%s\n", buf); - X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf); + X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof(buf)); BIO_printf(bio_s_out, "issuer=%s\n", buf); X509_free(peer); peer = NULL; } - if (SSL_get_shared_ciphers(con, buf, sizeof buf) != NULL) + if (SSL_get_shared_ciphers(con, buf, sizeof(buf)) != NULL) BIO_printf(bio_s_out, "Shared ciphers:%s\n", buf); str = SSL_CIPHER_get_name(SSL_get_current_cipher(con)); ssl_print_sigalgs(bio_s_out, con); diff --git a/apps/s_time.c b/apps/s_time.c index 3459573f1d..cb2a4fd552 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -225,7 +225,7 @@ int s_time_main(int argc, char **argv) goto end; if (www_path != NULL) { - buf_len = BIO_snprintf(buf, sizeof buf, + buf_len = BIO_snprintf(buf, sizeof(buf), fmt_http_get_cmd, www_path); if (SSL_write(scon, buf, buf_len) <= 0) goto end; @@ -285,7 +285,7 @@ int s_time_main(int argc, char **argv) } if (www_path != NULL) { - buf_len = BIO_snprintf(buf, sizeof buf, + buf_len = BIO_snprintf(buf, sizeof(buf), fmt_http_get_cmd, www_path); if (SSL_write(scon, buf, buf_len) <= 0) goto end; @@ -318,7 +318,7 @@ int s_time_main(int argc, char **argv) goto end; if (www_path) { - BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", + BIO_snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n", www_path); if (SSL_write(scon, buf, strlen(buf)) <= 0) goto end; diff --git a/apps/speed.c b/apps/speed.c index 5ee58d912b..bcc5d8ef31 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -2401,7 +2401,7 @@ int speed_main(int argc, char **argv) #ifndef OPENSSL_NO_DSA if (RAND_status() != 1) { - RAND_seed(rnd_seed, sizeof rnd_seed); + RAND_seed(rnd_seed, sizeof(rnd_seed)); } for (testnum = 0; testnum < DSA_NUM; testnum++) { int st = 0; @@ -2469,7 +2469,7 @@ int speed_main(int argc, char **argv) #ifndef OPENSSL_NO_EC if (RAND_status() != 1) { - RAND_seed(rnd_seed, sizeof rnd_seed); + RAND_seed(rnd_seed, sizeof(rnd_seed)); } for (testnum = 0; testnum < EC_NUM; testnum++) { int st = 1; @@ -2553,7 +2553,7 @@ int speed_main(int argc, char **argv) } if (RAND_status() != 1) { - RAND_seed(rnd_seed, sizeof rnd_seed); + RAND_seed(rnd_seed, sizeof(rnd_seed)); } for (testnum = 0; testnum < EC_NUM; testnum++) { int ecdh_checks = 1; @@ -2876,7 +2876,7 @@ static char *sstrsep(char **string, const char *delim) if (**string == 0) return NULL; - memset(isdelim, 0, sizeof isdelim); + memset(isdelim, 0, sizeof(isdelim)); isdelim[0] = 1; while (*delim) { @@ -2937,7 +2937,7 @@ static int do_multi(int multi) char *p; f = fdopen(fds[n], "r"); - while (fgets(buf, sizeof buf, f)) { + while (fgets(buf, sizeof(buf), f)) { p = strchr(buf, '\n'); if (p) *p = '\0'; diff --git a/apps/vms_term_sock.c b/apps/vms_term_sock.c index a7d87ff361..bc0c173ef4 100644 --- a/apps/vms_term_sock.c +++ b/apps/vms_term_sock.c @@ -143,7 +143,7 @@ int main (int argc, char *argv[], char *envp[]) ** Process the terminal input */ LogMessage ("Waiting on terminal I/O ...\n"); - len = recv (TermSock, TermBuff, sizeof (TermBuff), 0) ; + len = recv (TermSock, TermBuff, sizeof(TermBuff), 0) ; TermBuff[len] = '\0'; LogMessage ("Received terminal I/O [%s]", TermBuff); @@ -209,7 +209,7 @@ int TerminalSocket (int FunctionCode, int *ReturnSocket) TerminalDeviceAst, 0, TerminalDeviceBuff, - sizeof (TerminalDeviceBuff) - 2, + sizeof(TerminalDeviceBuff) - 2, 0, 0, 0, 0); if (! (status & 1)) { LogMessage ("TerminalSocket: SYS$QIO () - %08X", status); @@ -317,7 +317,7 @@ static int CreateSocketPair (int SocketFamily, /* ** Initialize the socket information */ - slen = sizeof (sin); + slen = sizeof(sin); memset ((char *) &sin, 0, slen); sin.sin_family = SocketFamily; sin.sin_addr.s_addr = inet_addr (LocalHostAddr); @@ -434,12 +434,12 @@ static int CreateSocketPair (int SocketFamily, /* ** Now issue the connect */ - memset ((char *) &sin, 0, sizeof (sin)) ; + memset ((char *) &sin, 0, sizeof(sin)) ; sin.sin_family = SocketFamily; sin.sin_addr.s_addr = inet_addr (LocalHostAddr) ; sin.sin_port = LocalHostPort ; - status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof (sin)); + status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof(sin)); if (status < 0 ) { LogMessage ("CreateSocketPair: connect () - %d", errno); sys$cantim (&sptb, 0); @@ -528,7 +528,7 @@ static int TerminalDeviceAst (int astparm) TerminalDeviceAst, 0, TerminalDeviceBuff, - sizeof (TerminalDeviceBuff) - 1, + sizeof(TerminalDeviceBuff) - 1, 0, 0, 0, 0); /* diff --git a/apps/x509.c b/apps/x509.c index cc5fbcaf1a..fd391164ed 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -726,11 +726,11 @@ int x509_main(int argc, char **argv) char *m; int len; - X509_NAME_oneline(X509_get_subject_name(x), buf, sizeof buf); + X509_NAME_oneline(X509_get_subject_name(x), buf, sizeof(buf)); BIO_printf(out, "/*\n" " * Subject: %s\n", buf); - X509_NAME_oneline(X509_get_issuer_name(x), buf, sizeof buf); + X509_NAME_oneline(X509_get_issuer_name(x), buf, sizeof(buf)); BIO_printf(out, " * Issuer: %s\n" " */\n", buf); diff --git a/crypto/asn1/a_mbstr.c b/crypto/asn1/a_mbstr.c index 5578e92397..7a035afbae 100644 --- a/crypto/asn1/a_mbstr.c +++ b/crypto/asn1/a_mbstr.c @@ -100,14 +100,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, if ((minsize > 0) && (nchar < minsize)) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT); - BIO_snprintf(strbuf, sizeof strbuf, "%ld", minsize); + BIO_snprintf(strbuf, sizeof(strbuf), "%ld", minsize); ERR_add_error_data(2, "minsize=", strbuf); return -1; } if ((maxsize > 0) && (nchar > maxsize)) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG); - BIO_snprintf(strbuf, sizeof strbuf, "%ld", maxsize); + BIO_snprintf(strbuf, sizeof(strbuf), "%ld", maxsize); ERR_add_error_data(2, "maxsize=", strbuf); return -1; } diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 79f0ecd2a8..1ec7a7e15f 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -42,7 +42,7 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) { int i, first, len = 0, c, use_bn; char ftmp[24], *tmp = ftmp; - int tmpsize = sizeof ftmp; + int tmpsize = sizeof(ftmp); const char *p; unsigned long l; BIGNUM *bl = NULL; @@ -177,7 +177,7 @@ int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a) if ((a == NULL) || (a->data == NULL)) return (BIO_write(bp, "NULL", 4)); - i = i2t_ASN1_OBJECT(buf, sizeof buf, a); + i = i2t_ASN1_OBJECT(buf, sizeof(buf), a); if (i > (int)(sizeof(buf) - 1)) { p = OPENSSL_malloc(i + 1); if (p == NULL) diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c index 933dda99b7..b91266b3c5 100644 --- a/crypto/asn1/a_strex.c +++ b/crypto/asn1/a_strex.c @@ -73,13 +73,13 @@ static int do_esc_char(unsigned long c, unsigned short flags, char *do_quotes, if (c > 0xffffffffL) return -1; if (c > 0xffff) { - BIO_snprintf(tmphex, sizeof tmphex, "\\W%08lX", c); + BIO_snprintf(tmphex, sizeof(tmphex), "\\W%08lX", c); if (!io_ch(arg, tmphex, 10)) return -1; return 10; } if (c > 0xff) { - BIO_snprintf(tmphex, sizeof tmphex, "\\U%04lX", c); + BIO_snprintf(tmphex, sizeof(tmphex), "\\U%04lX", c); if (!io_ch(arg, tmphex, 6)) return -1; return 6; @@ -183,7 +183,7 @@ static int do_buf(unsigned char *buf, int buflen, if (type & BUF_TYPE_CONVUTF8) { unsigned char utfbuf[6]; int utflen; - utflen = UTF8_putc(utfbuf, sizeof utfbuf, c); + utflen = UTF8_putc(utfbuf, sizeof(utfbuf), c); for (i = 0; i < utflen; i++) { /* * We don't need to worry about setting orflags correctly @@ -478,7 +478,7 @@ static int do_name_ex(char_io *io_ch, void *arg, const X509_NAME *n, if (fn_opt != XN_FLAG_FN_NONE) { int objlen, fld_len; if ((fn_opt == XN_FLAG_FN_OID) || (fn_nid == NID_undef)) { - OBJ_obj2txt(objtmp, sizeof objtmp, fn, 1); + OBJ_obj2txt(objtmp, sizeof(objtmp), fn, 1); fld_len = 0; /* XXX: what should this be? */ objbuf = objtmp; } else { diff --git a/crypto/asn1/asn1_par.c b/crypto/asn1/asn1_par.c index af045cb15e..fabc8d6fef 100644 --- a/crypto/asn1/asn1_par.c +++ b/crypto/asn1/asn1_par.c @@ -38,13 +38,13 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, p = str; if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) - BIO_snprintf(str, sizeof str, "priv [ %d ] ", tag); + BIO_snprintf(str, sizeof(str), "priv [ %d ] ", tag); else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC) - BIO_snprintf(str, sizeof str, "cont [ %d ]", tag); + BIO_snprintf(str, sizeof(str), "cont [ %d ]", tag); else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) - BIO_snprintf(str, sizeof str, "appl [ %d ]", tag); + BIO_snprintf(str, sizeof(str), "appl [ %d ]", tag); else if (tag > 30) - BIO_snprintf(str, sizeof str, "", tag); + BIO_snprintf(str, sizeof(str), "", tag); else p = ASN1_tag2str(tag); diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c index f53e9056aa..53a9ee8ee9 100644 --- a/crypto/asn1/tasn_prn.c +++ b/crypto/asn1/tasn_prn.c @@ -409,7 +409,7 @@ static int asn1_print_oid(BIO *out, const ASN1_OBJECT *oid) ln = OBJ_nid2ln(OBJ_obj2nid(oid)); if (!ln) ln = ""; - OBJ_obj2txt(objbuf, sizeof objbuf, oid, 1); + OBJ_obj2txt(objbuf, sizeof(objbuf), oid, 1); if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0) return 0; return 1; diff --git a/crypto/async/async.c b/crypto/async/async.c index 8c699af78e..9a4e6b2657 100644 --- a/crypto/async/async.c +++ b/crypto/async/async.c @@ -36,7 +36,7 @@ static async_ctx *async_ctx_new(void) { async_ctx *nctx = NULL; - nctx = OPENSSL_malloc(sizeof (async_ctx)); + nctx = OPENSSL_malloc(sizeof(async_ctx)); if (nctx == NULL) { ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE); goto err; @@ -81,7 +81,7 @@ static ASYNC_JOB *async_job_new(void) { ASYNC_JOB *job = NULL; - job = OPENSSL_zalloc(sizeof (ASYNC_JOB)); + job = OPENSSL_zalloc(sizeof(ASYNC_JOB)); if (job == NULL) { ASYNCerr(ASYNC_F_ASYNC_JOB_NEW, ERR_R_MALLOC_FAILURE); return NULL; @@ -330,7 +330,7 @@ int ASYNC_init_thread(size_t max_size, size_t init_size) return 0; } - pool = OPENSSL_zalloc(sizeof *pool); + pool = OPENSSL_zalloc(sizeof(*pool)); if (pool == NULL) { ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE); return 0; diff --git a/crypto/async/async_wait.c b/crypto/async/async_wait.c index e115985d22..0a0bf873e1 100644 --- a/crypto/async/async_wait.c +++ b/crypto/async/async_wait.c @@ -47,7 +47,7 @@ int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, { struct fd_lookup_st *fdlookup; - fdlookup = OPENSSL_zalloc(sizeof *fdlookup); + fdlookup = OPENSSL_zalloc(sizeof(*fdlookup)); if (fdlookup == NULL) return 0; diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index 6c2b0e906c..aea843a7b9 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -668,7 +668,7 @@ int BIO_lookup(const char *host, const char *service, int gai_ret = 0; struct addrinfo hints; - memset(&hints, 0, sizeof hints); + memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = socktype; diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index a27954fa34..c8601cb2b8 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -54,36 +54,36 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), if ((rows * dump_width) < len) rows++; for (i = 0; i < rows; i++) { - OPENSSL_strlcpy(buf, str, sizeof buf); - BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width); - OPENSSL_strlcat(buf, tmp, sizeof buf); + OPENSSL_strlcpy(buf, str, sizeof(buf)); + BIO_snprintf(tmp, sizeof(tmp), "%04x - ", i * dump_width); + OPENSSL_strlcat(buf, tmp, sizeof(buf)); for (j = 0; j < dump_width; j++) { if (((i * dump_width) + j) >= len) { - OPENSSL_strlcat(buf, " ", sizeof buf); + OPENSSL_strlcat(buf, " ", sizeof(buf)); } else { ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff; - BIO_snprintf(tmp, sizeof tmp, "%02x%c", ch, + BIO_snprintf(tmp, sizeof(tmp), "%02x%c", ch, j == 7 ? '-' : ' '); - OPENSSL_strlcat(buf, tmp, sizeof buf); + OPENSSL_strlcat(buf, tmp, sizeof(buf)); } } - OPENSSL_strlcat(buf, " ", sizeof buf); + OPENSSL_strlcat(buf, " ", sizeof(buf)); for (j = 0; j < dump_width; j++) { if (((i * dump_width) + j) >= len) break; ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff; #ifndef CHARSET_EBCDIC - BIO_snprintf(tmp, sizeof tmp, "%c", + BIO_snprintf(tmp, sizeof(tmp), "%c", ((ch >= ' ') && (ch <= '~')) ? ch : '.'); #else - BIO_snprintf(tmp, sizeof tmp, "%c", + BIO_snprintf(tmp, sizeof(tmp), "%c", ((ch >= os_toascii[' ']) && (ch <= os_toascii['~'])) ? os_toebcdic[ch] : '.'); #endif - OPENSSL_strlcat(buf, tmp, sizeof buf); + OPENSSL_strlcat(buf, tmp, sizeof(buf)); } - OPENSSL_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcat(buf, "\n", sizeof(buf)); /* * if this is the last call then update the ddt_dump thing so that we * will move the selection point in the debug window @@ -92,7 +92,7 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), } #ifdef TRUNCATE if (trc > 0) { - BIO_snprintf(buf, sizeof buf, "%s%04x - \n", str, + BIO_snprintf(buf, sizeof(buf), "%s%04x - \n", str, len + trc); ret += cb((void *)buf, strlen(buf), u); } diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c index 2dbfa12e04..cdfe05f93c 100644 --- a/crypto/bio/b_print.c +++ b/crypto/bio/b_print.c @@ -665,7 +665,7 @@ fmtfp(char **sbuffer, iconvert[iplace++] = "0123456789"[intpart % 10]; intpart = (intpart / 10); } while (intpart && (iplace < (int)sizeof(iconvert))); - if (iplace == sizeof iconvert) + if (iplace == sizeof(iconvert)) iplace--; iconvert[iplace] = 0; @@ -683,7 +683,7 @@ fmtfp(char **sbuffer, fracpart = (fracpart / 10); } - if (fplace == sizeof fconvert) + if (fplace == sizeof(fconvert)) fplace--; fconvert[fplace] = 0; diff --git a/crypto/bio/bio_cb.c b/crypto/bio/bio_cb.c index 69ea3d067e..412387b6b2 100644 --- a/crypto/bio/bio_cb.c +++ b/crypto/bio/bio_cb.c @@ -27,7 +27,7 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp, if (BIO_CB_RETURN & cmd) r = ret; - len = BIO_snprintf(buf, sizeof buf, "BIO[%p]: ", (void *)bio); + len = BIO_snprintf(buf, sizeof(buf), "BIO[%p]: ", (void *)bio); /* Ignore errors and continue printing the other information. */ if (len < 0) diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c index e3d8c0e483..ee18ff31a7 100644 --- a/crypto/bio/bss_file.c +++ b/crypto/bio/bss_file.c @@ -267,15 +267,15 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) b->shutdown = (int)num & BIO_CLOSE; if (num & BIO_FP_APPEND) { if (num & BIO_FP_READ) - OPENSSL_strlcpy(p, "a+", sizeof p); + OPENSSL_strlcpy(p, "a+", sizeof(p)); else - OPENSSL_strlcpy(p, "a", sizeof p); + OPENSSL_strlcpy(p, "a", sizeof(p)); } else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE)) - OPENSSL_strlcpy(p, "r+", sizeof p); + OPENSSL_strlcpy(p, "r+", sizeof(p)); else if (num & BIO_FP_WRITE) - OPENSSL_strlcpy(p, "w", sizeof p); + OPENSSL_strlcpy(p, "w", sizeof(p)); else if (num & BIO_FP_READ) - OPENSSL_strlcpy(p, "r", sizeof p); + OPENSSL_strlcpy(p, "r", sizeof(p)); else { BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE); ret = 0; diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c index 821676067b..5ffe2fc9ba 100644 --- a/crypto/bn/bn_print.c +++ b/crypto/bn/bn_print.c @@ -332,10 +332,10 @@ char *BN_options(void) if (!init) { init++; #ifdef BN_LLONG - BIO_snprintf(data, sizeof data, "bn(%d,%d)", + BIO_snprintf(data, sizeof(data), "bn(%d,%d)", (int)sizeof(BN_ULLONG) * 8, (int)sizeof(BN_ULONG) * 8); #else - BIO_snprintf(data, sizeof data, "bn(%d,%d)", + BIO_snprintf(data, sizeof(data), "bn(%d,%d)", (int)sizeof(BN_ULONG) * 8, (int)sizeof(BN_ULONG) * 8); #endif } diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index a7b11d1598..b443903f46 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -353,7 +353,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) OPENSSL_free(section); if (line != NULL) *line = eline; - BIO_snprintf(btmp, sizeof btmp, "%ld", eline); + BIO_snprintf(btmp, sizeof(btmp), "%ld", eline); ERR_add_error_data(2, "line ", btmp); if (h != conf->data) { CONF_free(conf->data); diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c index 31f838e0fa..543a8ea4ed 100644 --- a/crypto/conf/conf_mod.c +++ b/crypto/conf/conf_mod.c @@ -171,7 +171,7 @@ static int module_run(const CONF *cnf, const char *name, const char *value, if (!(flags & CONF_MFLAGS_SILENT)) { char rcode[DECIMAL_SIZE(ret) + 1]; CONFerr(CONF_F_MODULE_RUN, CONF_R_MODULE_INITIALIZATION_ERROR); - BIO_snprintf(rcode, sizeof rcode, "%-8d", ret); + BIO_snprintf(rcode, sizeof(rcode), "%-8d", ret); ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode); } diff --git a/crypto/des/ecb_enc.c b/crypto/des/ecb_enc.c index bd130c6e03..32df4600f2 100644 --- a/crypto/des/ecb_enc.c +++ b/crypto/des/ecb_enc.c @@ -24,7 +24,7 @@ const char *DES_options(void) size = "int"; else size = "long"; - BIO_snprintf(buf, sizeof buf, "des(%s)", size); + BIO_snprintf(buf, sizeof(buf), "des(%s)", size); init = 0; } return (buf); diff --git a/crypto/des/fcrypt.c b/crypto/des/fcrypt.c index 5215ad3e64..baede4fccf 100644 --- a/crypto/des/fcrypt.c +++ b/crypto/des/fcrypt.c @@ -77,7 +77,7 @@ char *DES_crypt(const char *buf, const char *salt) /* Convert password to ASCII. */ OPENSSL_strlcpy(e_buf, buf, sizeof(e_buf)); - ebcdic2ascii(e_buf, e_buf, sizeof e_buf); + ebcdic2ascii(e_buf, e_buf, sizeof(e_buf)); /* Encrypt it (from/to ASCII); if it worked, convert back. */ ret = DES_fcrypt(e_buf, e_salt, buff); diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 795d9549cf..dc88b8d041 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -319,7 +319,7 @@ void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) register int i; #ifdef OPENBSD_DEV_CRYPTO - memcpy(schedule->key, key, sizeof schedule->key); + memcpy(schedule->key, key, sizeof(schedule->key)); schedule->session = NULL; #endif k = &schedule->ks->deslong[0]; diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 036046231c..b39777fbf2 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -222,11 +222,11 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, totalnum = num + numblocks; - wsize = OPENSSL_malloc(totalnum * sizeof wsize[0]); - wNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]); - wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space - * for pivot */ - val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]); + wsize = OPENSSL_malloc(totalnum * sizeof(wsize[0])); + wNAF_len = OPENSSL_malloc(totalnum * sizeof(wNAF_len[0])); + /* include space for pivot */ + wNAF = OPENSSL_malloc((totalnum + 1) * sizeof(wNAF[0])); + val_sub = OPENSSL_malloc(totalnum * sizeof(val_sub[0])); /* Ensure wNAF is initialised in case we end up going to err */ if (wNAF != NULL) @@ -372,7 +372,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, * 'val_sub[i]' is a pointer to the subarray for the i-th point, or to a * subarray of 'pre_comp->points' if we already have precomputation. */ - val = OPENSSL_malloc((num_val + 1) * sizeof val[0]); + val = OPENSSL_malloc((num_val + 1) * sizeof(val[0])); if (val == NULL) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); goto err; diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c index c9bf078c93..1ff1344da6 100644 --- a/crypto/ec/ecp_nistp224.c +++ b/crypto/ec/ecp_nistp224.c @@ -337,7 +337,7 @@ static int BN_to_felem(felem out, const BIGNUM *bn) /* BN_bn2bin eats leading zeroes */ memset(b_out, 0, sizeof(b_out)); num_bytes = BN_num_bytes(bn); - if (num_bytes > sizeof b_out) { + if (num_bytes > sizeof(b_out)) { ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); return 0; } @@ -356,8 +356,8 @@ static BIGNUM *felem_to_BN(BIGNUM *out, const felem in) { felem_bytearray b_in, b_out; felem_to_bin28(b_in, in); - flip_endian(b_out, b_in, sizeof b_out); - return BN_bin2bn(b_out, sizeof b_out, out); + flip_endian(b_out, b_in, sizeof(b_out)); + return BN_bin2bn(b_out, sizeof(b_out), out); } /******************************************************************************/ diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index 6822a4b478..119be01be0 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -165,7 +165,7 @@ static int BN_to_felem(felem out, const BIGNUM *bn) /* BN_bn2bin eats leading zeroes */ memset(b_out, 0, sizeof(b_out)); num_bytes = BN_num_bytes(bn); - if (num_bytes > sizeof b_out) { + if (num_bytes > sizeof(b_out)) { ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); return 0; } @@ -184,8 +184,8 @@ static BIGNUM *smallfelem_to_BN(BIGNUM *out, const smallfelem in) { felem_bytearray b_in, b_out; smallfelem_to_bin32(b_in, in); - flip_endian(b_out, b_in, sizeof b_out); - return BN_bin2bn(b_out, sizeof b_out, out); + flip_endian(b_out, b_in, sizeof(b_out)); + return BN_bin2bn(b_out, sizeof(b_out), out); } /*- diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index 725cd92d96..def8f9328b 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -188,7 +188,7 @@ static int BN_to_felem(felem out, const BIGNUM *bn) /* BN_bn2bin eats leading zeroes */ memset(b_out, 0, sizeof(b_out)); num_bytes = BN_num_bytes(bn); - if (num_bytes > sizeof b_out) { + if (num_bytes > sizeof(b_out)) { ECerr(EC_F_BN_TO_FELEM, EC_R_BIGNUM_OUT_OF_RANGE); return 0; } @@ -207,8 +207,8 @@ static BIGNUM *felem_to_BN(BIGNUM *out, const felem in) { felem_bytearray b_in, b_out; felem_to_bin66(b_in, in); - flip_endian(b_out, b_in, sizeof b_out); - return BN_bin2bn(b_out, sizeof b_out, out); + flip_endian(b_out, b_in, sizeof(b_out)); + return BN_bin2bn(b_out, sizeof(b_out), out); } /*- diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c index 76e0caf907..abd3795046 100644 --- a/crypto/ec/ecp_smpl.c +++ b/crypto/ec/ecp_smpl.c @@ -1221,7 +1221,7 @@ int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, if (tmp == NULL || tmp_Z == NULL) goto err; - prod_Z = OPENSSL_malloc(num * sizeof prod_Z[0]); + prod_Z = OPENSSL_malloc(num * sizeof(prod_Z[0])); if (prod_Z == NULL) goto err; for (i = 0; i < num; i++) { diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c index c7dc1d151a..6ae12515f4 100644 --- a/crypto/err/err_prn.c +++ b/crypto/err/err_prn.c @@ -35,7 +35,7 @@ void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u), tid.tid = CRYPTO_THREAD_get_current_id(); while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) { - ERR_error_string_n(l, buf, sizeof buf); + ERR_error_string_n(l, buf, sizeof(buf)); BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", tid.ltid, buf, file, line, (flags & ERR_TXT_STRING) ? data : ""); if (cb(buf2, strlen(buf2), u) <= 0) diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 5ea14cd1cd..e5807edd65 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -392,7 +392,7 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) } b = ctx->cipher->block_size; - OPENSSL_assert(b <= sizeof ctx->buf); + OPENSSL_assert(b <= sizeof(ctx->buf)); if (b == 1) { *outl = 0; return 1; @@ -453,7 +453,7 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, if (ctx->flags & EVP_CIPH_NO_PADDING) return EVP_EncryptUpdate(ctx, out, outl, in, inl); - OPENSSL_assert(b <= sizeof ctx->final); + OPENSSL_assert(b <= sizeof(ctx->final)); if (ctx->final_used) { /* see comment about PTRDIFF_T comparison above */ @@ -525,7 +525,7 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_WRONG_FINAL_BLOCK_LENGTH); return (0); } - OPENSSL_assert(b <= sizeof ctx->final); + OPENSSL_assert(b <= sizeof(ctx->final)); /* * The following assumes that the ciphertext has been authenticated. diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index ce7aa2cfa1..eb7344c253 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -90,9 +90,9 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, char obj_tmp[80]; EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_PBE_ALGORITHM); if (!pbe_obj) - OPENSSL_strlcpy(obj_tmp, "NULL", sizeof obj_tmp); + OPENSSL_strlcpy(obj_tmp, "NULL", sizeof(obj_tmp)); else - i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj); + i2t_ASN1_OBJECT(obj_tmp, sizeof(obj_tmp), pbe_obj); ERR_add_error_data(2, "TYPE=", obj_tmp); return 0; } diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c index 365e240cc2..6d5f289b51 100644 --- a/crypto/evp/p5_crpt2.c +++ b/crypto/evp/p5_crpt2.c @@ -215,7 +215,7 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, goto err; } keylen = EVP_CIPHER_CTX_key_length(ctx); - OPENSSL_assert(keylen <= sizeof key); + OPENSSL_assert(keylen <= sizeof(key)); /* Decode parameter */ diff --git a/crypto/init.c b/crypto/init.c index cf65b14bf3..173eac3747 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -42,7 +42,7 @@ static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc) CRYPTO_THREAD_get_local(&threadstopkey); if (local == NULL && alloc) { - local = OPENSSL_zalloc(sizeof *local); + local = OPENSSL_zalloc(sizeof(*local)); if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) { OPENSSL_free(local); return NULL; diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index dc3f8ff571..c884078e77 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -466,7 +466,7 @@ static void print_leak(const MEM *m, MEM_LEAK *l) } tid; CRYPTO_THREAD_ID ti; -#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf)) +#define BUF_REMAIN (sizeof(buf) - (size_t)(bufp - buf)) lcl = localtime(&m->time); BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ", @@ -505,7 +505,7 @@ static void print_leak(const MEM *m, MEM_LEAK *l) memset(buf, '>', ami_cnt); tid.ltid = 0; tid.tid = amip->threadid; - BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt, + BIO_snprintf(buf + ami_cnt, sizeof(buf) - ami_cnt, " thread=%lu, file=%s, line=%d, info=\"", tid.ltid, amip->file, amip->line); @@ -515,10 +515,10 @@ static void print_leak(const MEM *m, MEM_LEAK *l) memcpy(buf + buf_len, amip->info, 128 - buf_len - 3); buf_len = 128 - 3; } else { - OPENSSL_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len); + OPENSSL_strlcpy(buf + buf_len, amip->info, sizeof(buf) - buf_len); buf_len = strlen(buf); } - BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n"); + BIO_snprintf(buf + buf_len, sizeof(buf) - buf_len, "\"\n"); BIO_puts(l->bio, buf); diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c index 2a08b21e6d..341347b0ea 100644 --- a/crypto/mem_sec.c +++ b/crypto/mem_sec.c @@ -373,7 +373,7 @@ static int sh_init(size_t size, int minsize) size_t pgsize; size_t aligned; - memset(&sh, 0, sizeof sh); + memset(&sh, 0, sizeof(sh)); /* make sure size and minsize are powers of 2 */ OPENSSL_assert(size > 0); @@ -400,7 +400,7 @@ static int sh_init(size_t size, int minsize) for (i = sh.bittable_size; i; i >>= 1) sh.freelist_size++; - sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof (char *)); + sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof(char *)); OPENSSL_assert(sh.freelist != NULL); if (sh.freelist == NULL) goto err; @@ -486,7 +486,7 @@ static void sh_done() OPENSSL_free(sh.bitmalloc); if (sh.map_result != NULL && sh.map_size) munmap(sh.map_result, sh.map_size); - memset(&sh, 0, sizeof sh); + memset(&sh, 0, sizeof(sh)); } static int sh_allocated(const char *ptr) diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index eb9c470fb1..53109acfea 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -500,7 +500,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) n += i; OPENSSL_free(bndec); } else { - BIO_snprintf(tbuf, sizeof tbuf, ".%lu", l); + BIO_snprintf(tbuf, sizeof(tbuf), ".%lu", l); i = strlen(tbuf); if (buf && (buf_len > 0)) { OPENSSL_strlcpy(buf, tbuf, buf_len); diff --git a/crypto/pem/pem_info.c b/crypto/pem/pem_info.c index dd493c8509..78d4476a2a 100644 --- a/crypto/pem/pem_info.c +++ b/crypto/pem/pem_info.c @@ -294,7 +294,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, /* create the right magic header stuff */ OPENSSL_assert(strlen(objstr) + 23 + 2 * EVP_CIPHER_iv_length(enc) + 13 <= - sizeof buf); + sizeof(buf)); buf[0] = '\0'; PEM_proc_type(buf, PEM_TYPE_ENCRYPTED); PEM_dek_info(buf, objstr, EVP_CIPHER_iv_length(enc), diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c index 3f53fd892d..e9202f44ae 100644 --- a/crypto/pem/pem_lib.c +++ b/crypto/pem/pem_lib.c @@ -357,7 +357,7 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, OPENSSL_cleanse(buf, PEM_BUFSIZE); OPENSSL_assert(strlen(objstr) + 23 + 2 * EVP_CIPHER_iv_length(enc) + 13 - <= sizeof buf); + <= sizeof(buf)); buf[0] = '\0'; PEM_proc_type(buf, PEM_TYPE_ENCRYPTED); diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c index fee722abf7..7d5fcb7f67 100644 --- a/crypto/rand/md_rand.c +++ b/crypto/rand/md_rand.c @@ -169,7 +169,7 @@ static int rand_add(const void *buf, int num, double add) md_c[0] = md_count[0]; md_c[1] = md_count[1]; - memcpy(local_md, md, sizeof md); + memcpy(local_md, md, sizeof(md)); /* state_index <= state_num <= STATE_SIZE */ state_index += num; @@ -416,7 +416,7 @@ static int rand_bytes(unsigned char *buf, int num, int pseudo) st_num = state_num; md_c[0] = md_count[0]; md_c[1] = md_count[1]; - memcpy(local_md, md, sizeof md); + memcpy(local_md, md, sizeof(md)); state_index += num_ceil; if (state_index > state_num) @@ -442,15 +442,15 @@ static int rand_bytes(unsigned char *buf, int num, int pseudo) goto err; #ifndef GETPID_IS_MEANINGLESS if (curr_pid) { /* just in the first iteration to save time */ - if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof curr_pid)) + if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof(curr_pid))) goto err; curr_pid = 0; } #endif if (curr_time) { /* just in the first iteration to save time */ - if (!MD_Update(m, (unsigned char *)&curr_time, sizeof curr_time)) + if (!MD_Update(m, (unsigned char *)&curr_time, sizeof(curr_time))) goto err; - if (!MD_Update(m, (unsigned char *)&tv, sizeof tv)) + if (!MD_Update(m, (unsigned char *)&tv, sizeof(tv))) goto err; curr_time = 0; if (!rand_hw_seed(m)) diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c index dd58b21498..50963b8e48 100644 --- a/crypto/rand/rand_egd.c +++ b/crypto/rand/rand_egd.c @@ -102,7 +102,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) addr.sun_family = AF_UNIX; if (strlen(path) >= sizeof(addr.sun_path)) return (-1); - OPENSSL_strlcpy(addr.sun_path, path, sizeof addr.sun_path); + OPENSSL_strlcpy(addr.sun_path, path, sizeof(addr.sun_path)); len = offsetof(struct sockaddr_un, sun_path) + strlen(path); fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index ecba2dc984..7a5a948430 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -80,15 +80,15 @@ int RAND_poll(void) */ curr_gid = getgid(); - RAND_add(&curr_gid, sizeof curr_gid, 1); + RAND_add(&curr_gid, sizeof(curr_gid), 1); curr_gid = 0; curr_pid = getpid(); - RAND_add(&curr_pid, sizeof curr_pid, 1); + RAND_add(&curr_pid, sizeof(curr_pid), 1); curr_pid = 0; curr_uid = getuid(); - RAND_add(&curr_uid, sizeof curr_uid, 1); + RAND_add(&curr_uid, sizeof(curr_uid), 1); curr_uid = 0; for (i = 0; i < (ENTROPY_NEEDED * 4); i++) { @@ -116,7 +116,7 @@ int RAND_poll(void) /* take 8 bits */ v = (unsigned char)(ts.tv_nsec % 256); - RAND_add(&v, sizeof v, 1); + RAND_add(&v, sizeof(v), 1); v = 0; } return 1; @@ -289,7 +289,7 @@ int RAND_poll(void) # if defined(DEVRANDOM) || (!defined(OPENSSL_NO_EGD) && defined(DEVRANDOM_EGD)) if (n > 0) { - RAND_add(tmpbuf, sizeof tmpbuf, (double)n); + RAND_add(tmpbuf, sizeof(tmpbuf), (double)n); OPENSSL_cleanse(tmpbuf, n); } # endif diff --git a/crypto/rsa/rsa_pss.c b/crypto/rsa/rsa_pss.c index 2aebbe9606..f8143387c8 100644 --- a/crypto/rsa/rsa_pss.c +++ b/crypto/rsa/rsa_pss.c @@ -111,7 +111,7 @@ int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, goto err; } if (!EVP_DigestInit_ex(ctx, Hash, NULL) - || !EVP_DigestUpdate(ctx, zeroes, sizeof zeroes) + || !EVP_DigestUpdate(ctx, zeroes, sizeof(zeroes)) || !EVP_DigestUpdate(ctx, mHash, hLen)) goto err; if (maskedDBLen - i) { @@ -207,7 +207,7 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, if (ctx == NULL) goto err; if (!EVP_DigestInit_ex(ctx, Hash, NULL) - || !EVP_DigestUpdate(ctx, zeroes, sizeof zeroes) + || !EVP_DigestUpdate(ctx, zeroes, sizeof(zeroes)) || !EVP_DigestUpdate(ctx, mHash, hLen)) goto err; if (sLen && !EVP_DigestUpdate(ctx, salt, sLen)) diff --git a/crypto/x509/t_x509.c b/crypto/x509/t_x509.c index eb65d88732..c7ced67f89 100644 --- a/crypto/x509/t_x509.c +++ b/crypto/x509/t_x509.c @@ -340,7 +340,7 @@ int X509_aux_print(BIO *out, X509 *x, int indent) BIO_puts(out, ", "); else first = 0; - OBJ_obj2txt(oidstr, sizeof oidstr, + OBJ_obj2txt(oidstr, sizeof(oidstr), sk_ASN1_OBJECT_value(trust, i), 0); BIO_puts(out, oidstr); } @@ -355,7 +355,7 @@ int X509_aux_print(BIO *out, X509 *x, int indent) BIO_puts(out, ", "); else first = 0; - OBJ_obj2txt(oidstr, sizeof oidstr, + OBJ_obj2txt(oidstr, sizeof(oidstr), sk_ASN1_OBJECT_value(reject, i), 0); BIO_puts(out, oidstr); } diff --git a/crypto/x509v3/v3_alt.c b/crypto/x509v3/v3_alt.c index 93f8c25c51..a35d3376b5 100644 --- a/crypto/x509v3/v3_alt.c +++ b/crypto/x509v3/v3_alt.c @@ -108,12 +108,12 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, case GEN_IPADD: p = gen->d.ip->data; if (gen->d.ip->length == 4) - BIO_snprintf(oline, sizeof oline, + BIO_snprintf(oline, sizeof(oline), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); else if (gen->d.ip->length == 16) { oline[0] = 0; for (i = 0; i < 8; i++) { - BIO_snprintf(htmp, sizeof htmp, "%X", p[0] << 8 | p[1]); + BIO_snprintf(htmp, sizeof(htmp), "%X", p[0] << 8 | p[1]); p += 2; strcat(oline, htmp); if (i != 7) diff --git a/crypto/x509v3/v3_info.c b/crypto/x509v3/v3_info.c index c29c7e2af6..a0bca5fb8e 100644 --- a/crypto/x509v3/v3_info.c +++ b/crypto/x509v3/v3_info.c @@ -77,7 +77,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS( goto err; tret = tmp; vtmp = sk_CONF_VALUE_value(tret, i); - i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method); + i2t_ASN1_OBJECT(objtmp, sizeof(objtmp), desc->method); nlen = strlen(objtmp) + strlen(vtmp->name) + 5; ntmp = OPENSSL_malloc(nlen); if (ntmp == NULL) diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c index 1686edd7b3..f674b79892 100644 --- a/ssl/record/rec_layer_d1.c +++ b/ssl/record/rec_layer_d1.c @@ -541,7 +541,7 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, unsigned int *dest_len = NULL; if (SSL3_RECORD_get_type(rr) == SSL3_RT_HANDSHAKE) { - dest_maxlen = sizeof s->rlayer.d->handshake_fragment; + dest_maxlen = sizeof(s->rlayer.d->handshake_fragment); dest = s->rlayer.d->handshake_fragment; dest_len = &s->rlayer.d->handshake_fragment_len; } else if (SSL3_RECORD_get_type(rr) == SSL3_RT_ALERT) { @@ -770,7 +770,7 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, s->rwstate = SSL_NOTHING; s->s3->fatal_alert = alert_descr; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); - BIO_snprintf(tmp, sizeof tmp, "%d", alert_descr); + BIO_snprintf(tmp, sizeof(tmp), "%d", alert_descr); ERR_add_error_data(2, "SSL alert number ", tmp); s->shutdown |= SSL_RECEIVED_SHUTDOWN; SSL_CTX_remove_session(s->session_ctx, s->session); diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 95026c6e57..ce3f93d2ae 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -757,7 +757,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf, totlen = 0; /* Clear our SSL3_RECORD structures */ - memset(wr, 0, sizeof wr); + memset(wr, 0, sizeof(wr)); for (j = 0; j < numpipes; j++) { /* write the header */ *(outbuf[j]++) = type & 0xff; @@ -1230,11 +1230,11 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, unsigned int *dest_len = NULL; if (SSL3_RECORD_get_type(rr) == SSL3_RT_HANDSHAKE) { - dest_maxlen = sizeof s->rlayer.handshake_fragment; + dest_maxlen = sizeof(s->rlayer.handshake_fragment); dest = s->rlayer.handshake_fragment; dest_len = &s->rlayer.handshake_fragment_len; } else if (SSL3_RECORD_get_type(rr) == SSL3_RT_ALERT) { - dest_maxlen = sizeof s->rlayer.alert_fragment; + dest_maxlen = sizeof(s->rlayer.alert_fragment); dest = s->rlayer.alert_fragment; dest_len = &s->rlayer.alert_fragment_len; } @@ -1405,7 +1405,7 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, s->rwstate = SSL_NOTHING; s->s3->fatal_alert = alert_descr; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); - BIO_snprintf(tmp, sizeof tmp, "%d", alert_descr); + BIO_snprintf(tmp, sizeof(tmp), "%d", alert_descr); ERR_add_error_data(2, "SSL alert number ", tmp); s->shutdown |= SSL_RECEIVED_SHUTDOWN; SSL3_RECORD_set_read(rr); diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 9ea02dc074..9ec50d09c5 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -2732,7 +2732,7 @@ static int cipher_compare(const void *a, const void *b) void ssl_sort_cipher_list(void) { - qsort(ssl3_ciphers, OSSL_NELEM(ssl3_ciphers), sizeof ssl3_ciphers[0], + qsort(ssl3_ciphers, OSSL_NELEM(ssl3_ciphers), sizeof(ssl3_ciphers[0]), cipher_compare); } diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 8699487af2..deaaeb0936 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -705,15 +705,15 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, char buf[1024]; int r; - if (strlen(dir) + strlen(filename) + 2 > sizeof buf) { + if (strlen(dir) + strlen(filename) + 2 > sizeof(buf)) { SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, SSL_R_PATH_TOO_LONG); goto err; } #ifdef OPENSSL_SYS_VMS - r = BIO_snprintf(buf, sizeof buf, "%s%s", dir, filename); + r = BIO_snprintf(buf, sizeof(buf), "%s%s", dir, filename); #else - r = BIO_snprintf(buf, sizeof buf, "%s/%s", dir, filename); + r = BIO_snprintf(buf, sizeof(buf), "%s/%s", dir, filename); #endif if (r <= 0 || r >= (int)sizeof(buf)) goto err; diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 6908f1677b..d259ff4294 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -669,7 +669,7 @@ SSL *SSL_new(SSL_CTX *ctx) s->verify_mode = ctx->verify_mode; s->not_resumable_session_cb = ctx->not_resumable_session_cb; s->sid_ctx_length = ctx->sid_ctx_length; - OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx); + OPENSSL_assert(s->sid_ctx_length <= sizeof(s->sid_ctx)); memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx)); s->verify_callback = ctx->default_verify_callback; s->generate_session_id = ctx->generate_session_id; @@ -793,7 +793,7 @@ int SSL_up_ref(SSL *s) int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, unsigned int sid_ctx_len) { - if (sid_ctx_len > sizeof ctx->sid_ctx) { + if (sid_ctx_len > sizeof(ctx->sid_ctx)) { SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT, SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); return 0; @@ -846,7 +846,7 @@ int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, */ SSL_SESSION r, *p; - if (id_len > sizeof r.session_id) + if (id_len > sizeof(r.session_id)) return 0; r.ssl_version = ssl->version; diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index f0274cf296..0dea8b5224 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -415,7 +415,7 @@ int ssl_get_new_session(SSL *s, int session) ss->session_id_length = 0; } - if (s->sid_ctx_length > sizeof ss->sid_ctx) { + if (s->sid_ctx_length > sizeof(ss->sid_ctx)) { SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR); SSL_SESSION_free(ss); return 0; @@ -759,8 +759,8 @@ void SSL_SESSION_free(SSL_SESSION *ss) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); - OPENSSL_cleanse(ss->master_key, sizeof ss->master_key); - OPENSSL_cleanse(ss->session_id, sizeof ss->session_id); + OPENSSL_cleanse(ss->master_key, sizeof(ss->master_key)); + OPENSSL_cleanse(ss->session_id, sizeof(ss->session_id)); X509_free(ss->peer); sk_X509_pop_free(ss->peer_chain, X509_free); sk_SSL_CIPHER_free(ss->ciphers); diff --git a/ssl/statem/statem_clnt.c b/ssl/statem/statem_clnt.c index 6606c65d5c..6fa3f1db67 100644 --- a/ssl/statem/statem_clnt.c +++ b/ssl/statem/statem_clnt.c @@ -935,7 +935,7 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) goto f_err; } session_id_len = PACKET_remaining(&session_id); - if (session_id_len > sizeof s->session->session_id + if (session_id_len > sizeof(s->session->session_id) || session_id_len > SSL3_SESSION_ID_SIZE) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_SSL3_SESSION_ID_TOO_LONG); diff --git a/test/bftest.c b/test/bftest.c index eb8d8a6fc2..a513660e4a 100644 --- a/test/bftest.c +++ b/test/bftest.c @@ -410,7 +410,7 @@ static int test(void) BF_set_key(&key, 16, cbc_key); memset(cbc_in, 0, sizeof(cbc_in)); memset(cbc_out, 0, sizeof(cbc_out)); - memcpy(iv, cbc_iv, sizeof iv); + memcpy(iv, cbc_iv, sizeof(iv)); BF_cbc_encrypt((unsigned char *)cbc_data, cbc_out, len, &key, iv, BF_ENCRYPT); if (memcmp(cbc_out, cbc_ok, 32) != 0) { diff --git a/test/bntest.c b/test/bntest.c index 3af2b83e0a..686eab8af8 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) results = 0; - RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */ + RAND_seed(rnd_seed, sizeof(rnd_seed)); /* or BN_generate_prime may fail */ argc--; argv++; diff --git a/test/d2i_test.c b/test/d2i_test.c index 13efba9684..5274270097 100644 --- a/test/d2i_test.c +++ b/test/d2i_test.c @@ -81,7 +81,7 @@ static int execute_test(D2I_TEST_FIXTURE fixture) * performs sanity checks on the input and can reject it before the * decoder is called. */ - len = BIO_read(bio, buf, sizeof buf); + len = BIO_read(bio, buf, sizeof(buf)); if (len < 0) goto err; diff --git a/test/dhtest.c b/test/dhtest.c index 8181fac368..ecf2d9dc70 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - RAND_seed(rnd_seed, sizeof rnd_seed); + RAND_seed(rnd_seed, sizeof(rnd_seed)); out = BIO_new(BIO_s_file()); if (out == NULL) diff --git a/test/dsatest.c b/test/dsatest.c index 10854224aa..3a62eb6934 100644 --- a/test/dsatest.c +++ b/test/dsatest.c @@ -93,7 +93,7 @@ int main(int argc, char **argv) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - RAND_seed(rnd_seed, sizeof rnd_seed); + RAND_seed(rnd_seed, sizeof(rnd_seed)); BIO_printf(bio_err, "test generation of DSA parameters\n"); diff --git a/test/ectest.c b/test/ectest.c index 0dd0ab85d8..d7b143200d 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -332,7 +332,7 @@ static void prime_field_tests(void) len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, - sizeof buf, ctx); + sizeof(buf), ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) @@ -345,7 +345,7 @@ static void prime_field_tests(void) len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, - sizeof buf, ctx); + sizeof(buf), ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) @@ -357,7 +357,7 @@ static void prime_field_tests(void) fprintf(stdout, "%02X", buf[i]); len = - EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, + EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof(buf), ctx); if (len == 0) ABORT; @@ -1113,7 +1113,7 @@ static void char2_field_tests(void) # ifdef OPENSSL_EC_BIN_PT_COMP len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, - sizeof buf, ctx); + sizeof(buf), ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) @@ -1127,7 +1127,7 @@ static void char2_field_tests(void) len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, - sizeof buf, ctx); + sizeof(buf), ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) @@ -1141,7 +1141,7 @@ static void char2_field_tests(void) /* Change test based on whether binary point compression is enabled or not. */ # ifdef OPENSSL_EC_BIN_PT_COMP len = - EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, + EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof(buf), ctx); if (len == 0) ABORT; @@ -1751,7 +1751,7 @@ int main(int argc, char *argv[]) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */ + RAND_seed(rnd_seed, sizeof(rnd_seed)); /* or BN_generate_prime may fail */ prime_field_tests(); puts(""); diff --git a/test/exptest.c b/test/exptest.c index e58e0c29aa..4221c1bed3 100644 --- a/test/exptest.c +++ b/test/exptest.c @@ -142,9 +142,11 @@ int main(int argc, char *argv[]) unsigned char c; BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple, *a, *b, *m; - RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we - * don't even check its return - * value (which we should) */ + /* + * See or BN_rand may fail, and we don't even check its return + * value (which we should) + */ + RAND_seed(rnd_seed, sizeof(rnd_seed)); ctx = BN_CTX_new(); if (ctx == NULL) diff --git a/test/igetest.c b/test/igetest.c index 1245860a5a..fe5bbf16e2 100644 --- a/test/igetest.c +++ b/test/igetest.c @@ -159,16 +159,16 @@ static int run_test_vectors(void) assert(v->length <= MAX_VECTOR_SIZE); if (v->encrypt == AES_ENCRYPT) - AES_set_encrypt_key(v->key, 8 * sizeof v->key, &key); + AES_set_encrypt_key(v->key, 8 * sizeof(v->key), &key); else - AES_set_decrypt_key(v->key, 8 * sizeof v->key, &key); - memcpy(iv, v->iv, sizeof iv); + AES_set_decrypt_key(v->key, 8 * sizeof(v->key), &key); + memcpy(iv, v->iv, sizeof(iv)); AES_ige_encrypt(v->in, buf, v->length, &key, iv, v->encrypt); if (memcmp(v->out, buf, v->length)) { printf("IGE test vector %d failed\n", n); - hexdump(stdout, "key", v->key, sizeof v->key); - hexdump(stdout, "iv", v->iv, sizeof v->iv); + hexdump(stdout, "key", v->key, sizeof(v->key)); + hexdump(stdout, "iv", v->iv, sizeof(v->iv)); hexdump(stdout, "in", v->in, v->length); hexdump(stdout, "expected", v->out, v->length); hexdump(stdout, "got", buf, v->length); @@ -177,14 +177,14 @@ static int run_test_vectors(void) } /* try with in == out */ - memcpy(iv, v->iv, sizeof iv); + memcpy(iv, v->iv, sizeof(iv)); memcpy(buf, v->in, v->length); AES_ige_encrypt(buf, buf, v->length, &key, iv, v->encrypt); if (memcmp(v->out, buf, v->length)) { printf("IGE test vector %d failed (with in == out)\n", n); - hexdump(stdout, "key", v->key, sizeof v->key); - hexdump(stdout, "iv", v->iv, sizeof v->iv); + hexdump(stdout, "key", v->key, sizeof(v->key)); + hexdump(stdout, "iv", v->iv, sizeof(v->iv)); hexdump(stdout, "in", v->in, v->length); hexdump(stdout, "expected", v->out, v->length); hexdump(stdout, "got", buf, v->length); @@ -214,9 +214,9 @@ static int run_test_vectors(void) if (memcmp(v->out, buf, v->length)) { printf("Bidirectional IGE test vector %d failed\n", n); - hexdump(stdout, "key 1", v->key1, sizeof v->key1); - hexdump(stdout, "key 2", v->key2, sizeof v->key2); - hexdump(stdout, "iv", v->iv, sizeof v->iv); + hexdump(stdout, "key 1", v->key1, sizeof(v->key1)); + hexdump(stdout, "key 2", v->key2, sizeof(v->key2)); + hexdump(stdout, "iv", v->iv, sizeof(v->iv)); hexdump(stdout, "in", v->in, v->length); hexdump(stdout, "expected", v->out, v->length); hexdump(stdout, "got", buf, v->length); @@ -245,19 +245,19 @@ int main(int argc, char **argv) assert(BIG_TEST_SIZE >= TEST_SIZE); - RAND_bytes(rkey, sizeof rkey); - RAND_bytes(plaintext, sizeof plaintext); - RAND_bytes(iv, sizeof iv); - memcpy(saved_iv, iv, sizeof saved_iv); + RAND_bytes(rkey, sizeof(rkey)); + RAND_bytes(plaintext, sizeof(plaintext)); + RAND_bytes(iv, sizeof(iv)); + memcpy(saved_iv, iv, sizeof(saved_iv)); /* Forward IGE only... */ /* Straight encrypt/decrypt */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); + AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key); AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE, &key, iv, AES_ENCRYPT); - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - memcpy(iv, saved_iv, sizeof iv); + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + memcpy(iv, saved_iv, sizeof(iv)); AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT); if (memcmp(checktext, plaintext, TEST_SIZE)) { @@ -268,16 +268,16 @@ int main(int argc, char **argv) } /* Now check encrypt chaining works */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); - memcpy(iv, saved_iv, sizeof iv); + AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key); + memcpy(iv, saved_iv, sizeof(iv)); AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE / 2, &key, iv, AES_ENCRYPT); AES_ige_encrypt(plaintext + TEST_SIZE / 2, ciphertext + TEST_SIZE / 2, TEST_SIZE / 2, &key, iv, AES_ENCRYPT); - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - memcpy(iv, saved_iv, sizeof iv); + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + memcpy(iv, saved_iv, sizeof(iv)); AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT); if (memcmp(checktext, plaintext, TEST_SIZE)) { @@ -288,16 +288,16 @@ int main(int argc, char **argv) } /* And check decrypt chaining */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); - memcpy(iv, saved_iv, sizeof iv); + AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key); + memcpy(iv, saved_iv, sizeof(iv)); AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE / 2, &key, iv, AES_ENCRYPT); AES_ige_encrypt(plaintext + TEST_SIZE / 2, ciphertext + TEST_SIZE / 2, TEST_SIZE / 2, &key, iv, AES_ENCRYPT); - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - memcpy(iv, saved_iv, sizeof iv); + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + memcpy(iv, saved_iv, sizeof(iv)); AES_ige_encrypt(ciphertext, checktext, TEST_SIZE / 2, &key, iv, AES_DECRYPT); AES_ige_encrypt(ciphertext + TEST_SIZE / 2, @@ -312,29 +312,29 @@ int main(int argc, char **argv) } /* make sure garble extends forwards only */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); - memcpy(iv, saved_iv, sizeof iv); - AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, + AES_set_encrypt_key(rkey, 8 * sizeof(rkey),&key); + memcpy(iv, saved_iv, sizeof(iv)); + AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv, AES_ENCRYPT); /* corrupt halfway through */ - ++ciphertext[sizeof ciphertext / 2]; - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - memcpy(iv, saved_iv, sizeof iv); - AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, + ++ciphertext[sizeof(ciphertext) / 2]; + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + memcpy(iv, saved_iv, sizeof(iv)); + AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv, AES_DECRYPT); matches = 0; - for (n = 0; n < sizeof checktext; ++n) + for (n = 0; n < sizeof(checktext); ++n) if (checktext[n] == plaintext[n]) ++matches; - if (matches > sizeof checktext / 2 + sizeof checktext / 100) { + if (matches > sizeof(checktext) / 2 + sizeof(checktext) / 100) { printf("More than 51%% matches after garbling\n"); ++err; } - if (matches < sizeof checktext / 2) { + if (matches < sizeof(checktext) / 2) { printf("Garble extends backwards!\n"); ++err; } @@ -346,16 +346,16 @@ int main(int argc, char **argv) */ /* possible with biIGE, so the IV is not updated. */ - RAND_bytes(rkey2, sizeof rkey2); + RAND_bytes(rkey2, sizeof(rkey2)); /* Straight encrypt/decrypt */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2); + AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2); AES_bi_ige_encrypt(plaintext, ciphertext, TEST_SIZE, &key, &key2, iv, AES_ENCRYPT); - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2); + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2); AES_bi_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, &key2, iv, AES_DECRYPT); @@ -367,70 +367,70 @@ int main(int argc, char **argv) } /* make sure garble extends both ways */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2); - AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, + AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2); + AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv, AES_ENCRYPT); /* corrupt halfway through */ - ++ciphertext[sizeof ciphertext / 2]; - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2); - AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, + ++ciphertext[sizeof(ciphertext) / 2]; + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2); + AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv, AES_DECRYPT); matches = 0; - for (n = 0; n < sizeof checktext; ++n) + for (n = 0; n < sizeof(checktext); ++n) if (checktext[n] == plaintext[n]) ++matches; - if (matches > sizeof checktext / 100) { + if (matches > sizeof(checktext) / 100) { printf("More than 1%% matches after bidirectional garbling\n"); ++err; } /* make sure garble extends both ways (2) */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2); - AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, + AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2); + AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv, AES_ENCRYPT); /* corrupt right at the end */ - ++ciphertext[sizeof ciphertext - 1]; - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2); - AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, + ++ciphertext[sizeof(ciphertext) - 1]; + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2); + AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv, AES_DECRYPT); matches = 0; - for (n = 0; n < sizeof checktext; ++n) + for (n = 0; n < sizeof(checktext); ++n) if (checktext[n] == plaintext[n]) ++matches; - if (matches > sizeof checktext / 100) { + if (matches > sizeof(checktext) / 100) { printf("More than 1%% matches after bidirectional garbling (2)\n"); ++err; } /* make sure garble extends both ways (3) */ - AES_set_encrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_encrypt_key(rkey2, 8 * sizeof rkey2, &key2); - AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, + AES_set_encrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_encrypt_key(rkey2, 8 * sizeof(rkey2), &key2); + AES_ige_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv, AES_ENCRYPT); /* corrupt right at the start */ ++ciphertext[0]; - AES_set_decrypt_key(rkey, 8 * sizeof rkey, &key); - AES_set_decrypt_key(rkey2, 8 * sizeof rkey2, &key2); - AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, + AES_set_decrypt_key(rkey, 8 * sizeof(rkey), &key); + AES_set_decrypt_key(rkey2, 8 * sizeof(rkey2), &key2); + AES_ige_encrypt(ciphertext, checktext, sizeof(checktext), &key, iv, AES_DECRYPT); matches = 0; - for (n = 0; n < sizeof checktext; ++n) + for (n = 0; n < sizeof(checktext); ++n) if (checktext[n] == plaintext[n]) ++matches; - if (matches > sizeof checktext / 100) { + if (matches > sizeof(checktext) / 100) { printf("More than 1%% matches after bidirectional garbling (3)\n"); ++err; } diff --git a/test/rsa_test.c b/test/rsa_test.c index 7d06394c6c..01e8374a09 100644 --- a/test/rsa_test.c +++ b/test/rsa_test.c @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */ + RAND_seed(rnd_seed, sizeof(rnd_seed)); /* or OAEP may fail */ plen = sizeof(ptext_ex) - 1; diff --git a/test/sanitytest.c b/test/sanitytest.c index 9c968f46d9..f1228f1494 100644 --- a/test/sanitytest.c +++ b/test/sanitytest.c @@ -44,7 +44,7 @@ int main() /* Is NULL equivalent to all-bytes-zero? */ p = NULL; - memset(bytes, 0, sizeof bytes); + memset(bytes, 0, sizeof(bytes)); TEST(memcmp(&p, bytes, sizeof(bytes)) == 0); /* Enum size */ diff --git a/test/ssltest_old.c b/test/ssltest_old.c index 8f7e1e00d1..83e3e73538 100644 --- a/test/ssltest_old.c +++ b/test/ssltest_old.c @@ -1014,7 +1014,7 @@ int main(int argc, char *argv[]) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - RAND_seed(rnd_seed, sizeof rnd_seed); + RAND_seed(rnd_seed, sizeof(rnd_seed)); bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT); @@ -1580,9 +1580,9 @@ int main(int argc, char *argv[]) { int session_id_context = 0; if (!SSL_CTX_set_session_id_context(s_ctx, (void *)&session_id_context, - sizeof session_id_context) || + sizeof(session_id_context)) || !SSL_CTX_set_session_id_context(s_ctx2, (void *)&session_id_context, - sizeof session_id_context)) { + sizeof(session_id_context))) { ERR_print_errors(bio_err); goto end; } @@ -2049,8 +2049,8 @@ int doit_localhost(SSL *s_ssl, SSL *c_ssl, int family, long count, if (cw_num > 0) { /* Write to server. */ - if (cw_num > (long)sizeof cbuf) - i = sizeof cbuf; + if (cw_num > (long)sizeof(cbuf)) + i = sizeof(cbuf); else i = (int)cw_num; r = BIO_write(c_ssl_bio, cbuf, i); @@ -2128,8 +2128,8 @@ int doit_localhost(SSL *s_ssl, SSL *c_ssl, int family, long count, if (sw_num > 0) { /* Write to client. */ - if (sw_num > (long)sizeof sbuf) - i = sizeof sbuf; + if (sw_num > (long)sizeof(sbuf)) + i = sizeof(sbuf); else i = (int)sw_num; r = BIO_write(s_ssl_bio, sbuf, i); @@ -2320,8 +2320,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, if (cw_num > 0) { /* Write to server. */ - if (cw_num > (long)sizeof cbuf) - i = sizeof cbuf; + if (cw_num > (long)sizeof(cbuf)) + i = sizeof(cbuf); else i = (int)cw_num; r = BIO_write(c_ssl_bio, cbuf, i); @@ -2399,8 +2399,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, if (sw_num > 0) { /* Write to client. */ - if (sw_num > (long)sizeof sbuf) - i = sizeof sbuf; + if (sw_num > (long)sizeof(sbuf)) + i = sizeof(sbuf); else i = (int)sw_num; r = BIO_write(s_ssl_bio, sbuf, i); @@ -2916,7 +2916,7 @@ static int verify_callback(int ok, X509_STORE_CTX *ctx) char *s, buf[256]; s = X509_NAME_oneline(X509_get_subject_name(X509_STORE_CTX_get_current_cert(ctx)), - buf, sizeof buf); + buf, sizeof(buf)); if (s != NULL) { if (ok) printf("depth=%d %s\n", X509_STORE_CTX_get_error_depth(ctx), buf); -- 2.25.1