Commit c6738fd2 authored by Rich Salz's avatar Rich Salz
Browse files

Standardize syntax around sizeof(foo)

parent a1daedd8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
#endif

    if (file == NULL)
        file = RAND_file_name(buffer, sizeof buffer);
        file = RAND_file_name(buffer, sizeof(buffer));
    else if (RAND_egd(file) > 0) {
        /*
         * we try if the given filename is an EGD socket. if it is, we don't
@@ -203,7 +203,7 @@ int app_RAND_write_file(const char *file, BIO *bio_e)
        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_e, "unable to write 'random state'\n");
        return 0;
+31 −31
Original line number Diff line number Diff line
@@ -1738,9 +1738,9 @@ int save_serial(char *serialfile, char *suffix, BIGNUM *serial,
        BUF_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
    }
#ifdef RL_DEBUG
@@ -1789,14 +1789,14 @@ int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
        goto err;
    }
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, new_suffix);
    j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", serialfile, new_suffix);
#else
    j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, new_suffix);
    j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", serialfile, new_suffix);
#endif
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", serialfile, old_suffix);
    j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", serialfile, old_suffix);
#else
    j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", serialfile, old_suffix);
    j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", serialfile, old_suffix);
#endif
#ifdef RL_DEBUG
    BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
@@ -1877,9 +1877,9 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
        goto err;

#ifndef OPENSSL_SYS_VMS
    BIO_snprintf(buf[0], sizeof buf[0], "%s.attr", dbfile);
    BIO_snprintf(buf[0], sizeof(buf[0]), "%s.attr", dbfile);
#else
    BIO_snprintf(buf[0], sizeof buf[0], "%s-attr", dbfile);
    BIO_snprintf(buf[0], sizeof(buf[0]), "%s-attr", dbfile);
#endif
    dbattr_conf = NCONF_new(NULL);
    if (NCONF_load(dbattr_conf, buf[0], &errorline) <= 0) {
@@ -1967,19 +1967,19 @@ 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[2], sizeof(buf[2]), "%s.attr", dbfile);
#else
    j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr", dbfile);
    j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr", dbfile);
#endif
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[1], sizeof buf[1], "%s.attr.%s", dbfile, suffix);
    j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.attr.%s", dbfile, suffix);
#else
    j = BIO_snprintf(buf[1], sizeof buf[1], "%s-attr-%s", dbfile, suffix);
    j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-attr-%s", dbfile, suffix);
#endif
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, suffix);
    j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, suffix);
#else
    j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, suffix);
    j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, suffix);
#endif
#ifdef RL_DEBUG
    BIO_printf(bio_err, "DEBUG: writing \"%s\"\n", buf[0]);
@@ -2028,29 +2028,29 @@ 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[4], sizeof(buf[4]), "%s.attr", dbfile);
#else
    j = BIO_snprintf(buf[4], sizeof buf[4], "%s-attr", dbfile);
    j = BIO_snprintf(buf[4], sizeof(buf[4]), "%s-attr", dbfile);
#endif
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr.%s", dbfile, new_suffix);
    j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s.attr.%s", dbfile, new_suffix);
#else
    j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr-%s", dbfile, new_suffix);
    j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr-%s", dbfile, new_suffix);
#endif
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, new_suffix);
    j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, new_suffix);
#else
    j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, new_suffix);
    j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, new_suffix);
#endif
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", dbfile, old_suffix);
    j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", dbfile, old_suffix);
#else
    j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", dbfile, old_suffix);
    j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", dbfile, old_suffix);
#endif
#ifndef OPENSSL_SYS_VMS
    j = BIO_snprintf(buf[3], sizeof buf[3], "%s.attr.%s", dbfile, old_suffix);
    j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s.attr.%s", dbfile, old_suffix);
#else
    j = BIO_snprintf(buf[3], sizeof buf[3], "%s-attr-%s", dbfile, old_suffix);
    j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s-attr-%s", dbfile, old_suffix);
#endif
#ifdef RL_DEBUG
    BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n", dbfile, buf[1]);
@@ -2604,7 +2604,7 @@ static void jpake_send_step3a(BIO *bconn, JPAKE_CTX *ctx)

    JPAKE_STEP3A_init(&s3a);
    JPAKE_STEP3A_generate(&s3a, ctx);
    BIO_write(bconn, s3a.hhk, sizeof s3a.hhk);
    BIO_write(bconn, s3a.hhk, sizeof(s3a.hhk));
    (void)BIO_flush(bconn);
    JPAKE_STEP3A_release(&s3a);
}
@@ -2615,7 +2615,7 @@ static void jpake_send_step3b(BIO *bconn, JPAKE_CTX *ctx)

    JPAKE_STEP3B_init(&s3b);
    JPAKE_STEP3B_generate(&s3b, ctx);
    BIO_write(bconn, s3b.hk, sizeof s3b.hk);
    BIO_write(bconn, s3b.hk, sizeof(s3b.hk));
    (void)BIO_flush(bconn);
    JPAKE_STEP3B_release(&s3b);
}
@@ -2625,7 +2625,7 @@ static void readbn(BIGNUM **bn, BIO *bconn)
    char buf[10240];
    int l;

    l = BIO_gets(bconn, buf, sizeof buf);
    l = BIO_gets(bconn, buf, sizeof(buf));
    assert(l > 0);
    assert(buf[l - 1] == '\n');
    buf[l - 1] = '\0';
@@ -2672,8 +2672,8 @@ static void jpake_receive_step3a(JPAKE_CTX *ctx, BIO *bconn)
    int l;

    JPAKE_STEP3A_init(&s3a);
    l = BIO_read(bconn, s3a.hhk, sizeof s3a.hhk);
    assert(l == sizeof s3a.hhk);
    l = BIO_read(bconn, s3a.hhk, sizeof(s3a.hhk));
    assert(l == sizeof(s3a.hhk));
    if (!JPAKE_STEP3A_process(ctx, &s3a)) {
        ERR_print_errors(bio_err);
        exit(1);
@@ -2687,8 +2687,8 @@ static void jpake_receive_step3b(JPAKE_CTX *ctx, BIO *bconn)
    int l;

    JPAKE_STEP3B_init(&s3b);
    l = BIO_read(bconn, s3b.hk, sizeof s3b.hk);
    assert(l == sizeof s3b.hk);
    l = BIO_read(bconn, s3b.hk, sizeof(s3b.hk));
    assert(l == sizeof(s3b.hk));
    if (!JPAKE_STEP3B_process(ctx, &s3b)) {
        ERR_print_errors(bio_err);
        exit(1);
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ int MAIN(int argc, char **argv)
                BIO_printf(STDout, "%s - ", nm);
            }
#endif
            BIO_puts(STDout, SSL_CIPHER_description(c, buf, sizeof buf));
            BIO_puts(STDout, SSL_CIPHER_description(c, buf, sizeof(buf)));
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ int MAIN(int argc, char **argv)
        goto end;

    /* first check the program name */
    program_name(argv[0], pname, sizeof pname);
    program_name(argv[0], pname, sizeof(pname));

    md = EVP_get_digestbyname(pname);

+12 −12
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ int MAIN(int, char **);
int MAIN(int argc, char **argv)
{
    static const char magic[] = "Salted__";
    char mbuf[sizeof magic - 1];
    char mbuf[sizeof(magic) - 1];
    char *strbuf = NULL;
    unsigned char *buff = NULL, *bufsize = NULL;
    int bsize = BSIZE, verbose = 0;
@@ -154,7 +154,7 @@ int MAIN(int argc, char **argv)
        goto end;

    /* first check the program name */
    program_name(argv[0], pname, sizeof pname);
    program_name(argv[0], pname, sizeof(pname));
    if (strcmp(pname, "base64") == 0)
        base64 = 1;
#ifdef ZLIB
@@ -247,7 +247,7 @@ int MAIN(int argc, char **argv)
                goto bad;
            }
            buf[0] = '\0';
            if (!fgets(buf, sizeof buf, infile)) {
            if (!fgets(buf, sizeof(buf), infile)) {
                BIO_printf(bio_err, "unable to read key from '%s'\n", file);
                goto bad;
            }
@@ -432,7 +432,7 @@ int MAIN(int argc, char **argv)
        for (;;) {
            char buf[200];

            BIO_snprintf(buf, sizeof buf, "enter %s %s password:",
            BIO_snprintf(buf, sizeof(buf), "enter %s %s password:",
                         OBJ_nid2ln(EVP_CIPHER_nid(cipher)),
                         (enc) ? "encryption" : "decryption");
            strbuf[0] = '\0';
@@ -517,31 +517,31 @@ int 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;
                }
@@ -564,7 +564,7 @@ int 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;
            }
Loading