Restore beck's rev 1.7: snprintf() was reviewed.
authorguenther <guenther@openbsd.org>
Sun, 20 Apr 2014 19:52:41 +0000 (19:52 +0000)
committerguenther <guenther@openbsd.org>
Sun, 20 Apr 2014 19:52:41 +0000 (19:52 +0000)
Also, use sizeof() for snprintf()'s size argument

lib/libcrypto/pem/pem_pkey.c
lib/libssl/src/crypto/pem/pem_pkey.c

index c8cf00d..5274447 100644 (file)
@@ -147,7 +147,8 @@ int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
                                                        (char *)kstr, klen,
                                                        cb, u);
 
-       snprintf(pem_str, 80, "%s PRIVATE KEY", x->ameth->pem_str);
+       (void) snprintf(pem_str, sizeof(pem_str), "%s PRIVATE KEY",
+           x->ameth->pem_str);
        return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey,
                                pem_str,bp,x,enc,kstr,klen,cb,u);
        }
@@ -199,7 +200,8 @@ int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x)
        if (!x->ameth || !x->ameth->param_encode)
                return 0;
 
-       snprintf(pem_str, 80, "%s PARAMETERS", x->ameth->pem_str);
+       (void) snprintf(pem_str, sizeof(pem_str), "%s PARAMETERS",
+           x->ameth->pem_str);
        return PEM_ASN1_write_bio(
                (i2d_of_void *)x->ameth->param_encode,
                                pem_str,bp,x,NULL,NULL,0,0,NULL);
index c8cf00d..5274447 100644 (file)
@@ -147,7 +147,8 @@ int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
                                                        (char *)kstr, klen,
                                                        cb, u);
 
-       snprintf(pem_str, 80, "%s PRIVATE KEY", x->ameth->pem_str);
+       (void) snprintf(pem_str, sizeof(pem_str), "%s PRIVATE KEY",
+           x->ameth->pem_str);
        return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey,
                                pem_str,bp,x,enc,kstr,klen,cb,u);
        }
@@ -199,7 +200,8 @@ int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x)
        if (!x->ameth || !x->ameth->param_encode)
                return 0;
 
-       snprintf(pem_str, 80, "%s PARAMETERS", x->ameth->pem_str);
+       (void) snprintf(pem_str, sizeof(pem_str), "%s PARAMETERS",
+           x->ameth->pem_str);
        return PEM_ASN1_write_bio(
                (i2d_of_void *)x->ameth->param_encode,
                                pem_str,bp,x,NULL,NULL,0,0,NULL);