Use safer sizeof variant in malloc
authorRich Salz <rsalz@akamai.com>
Sat, 2 May 2015 03:10:31 +0000 (23:10 -0400)
committerRich Salz <rsalz@openssl.org>
Mon, 4 May 2015 19:00:13 +0000 (15:00 -0400)
commitb4faea50c35d92a67d1369355b49cc3efba78406
treecfebea69d625f936c9fd7281f1fa3eaa2fa38834
parent8920a7cd04f43b1a090d0b0a8c9e16b94c6898d4
Use safer sizeof variant in malloc

For a local variable:
        TYPE *p;
Allocations like this are "risky":
        p = OPENSSL_malloc(sizeof(TYPE));
if the type of p changes, and the malloc call isn't updated, you
could get memory corruption.  Instead do this:
        p = OPENSSL_malloc(sizeof(*p));
Also fixed a few memset() calls that I noticed while doing this.

Reviewed-by: Richard Levitte <levitte@openssl.org>
142 files changed:
apps/apps.c
apps/ca.c
apps/cms.c
apps/ecparam.c
apps/openssl.c
apps/s_cb.c
apps/s_server.c
apps/speed.c
apps/srp.c
apps/vms_decc_init.c
crypto/LPdir_unix.c
crypto/LPdir_vms.c
crypto/LPdir_win.c
crypto/asn1/a_object.c
crypto/asn1/a_strnid.c
crypto/asn1/ameth_lib.c
crypto/asn1/asn1_lib.c
crypto/asn1/asn_mime.c
crypto/asn1/bio_asn1.c
crypto/asn1/bio_ndef.c
crypto/asn1/tasn_new.c
crypto/asn1/tasn_prn.c
crypto/asn1/tasn_scn.c
crypto/asn1/x_crl.c
crypto/asn1/x_info.c
crypto/asn1/x_pkey.c
crypto/bio/bf_buff.c
crypto/bio/bf_lbuf.c
crypto/bio/bf_nbio.c
crypto/bio/bio_lib.c
crypto/bio/bss_acpt.c
crypto/bio/bss_bio.c
crypto/bio/bss_conn.c
crypto/bio/bss_dgram.c
crypto/bn/Makefile
crypto/bn/bn_blind.c
crypto/bn/bn_ctx.c
crypto/bn/bn_gf2m.c
crypto/bn/bn_lib.c
crypto/bn/bn_mont.c
crypto/bn/bn_recp.c
crypto/buffer/buffer.c
crypto/cmac/cmac.c
crypto/comp/c_zlib.c
crypto/comp/comp_lib.c
crypto/conf/conf_api.c
crypto/conf/conf_def.c
crypto/conf/conf_mod.c
crypto/dh/dh_lib.c
crypto/dh/dh_pmeth.c
crypto/dsa/dsa_asn1.c
crypto/dsa/dsa_lib.c
crypto/dsa/dsa_pmeth.c
crypto/dso/dso_lib.c
crypto/dso/dso_vms.c
crypto/dso/dso_win32.c
crypto/ec/Makefile
crypto/ec/ec_key.c
crypto/ec/ec_lib.c
crypto/ec/ec_mult.c
crypto/ec/ec_pmeth.c
crypto/ec/ecp_nistp224.c
crypto/ec/ecp_nistp256.c
crypto/ec/ecp_nistp521.c
crypto/ec/ecp_nistz256.c
crypto/ecdh/ech_lib.c
crypto/ecdsa/ecs_lib.c
crypto/engine/eng_dyn.c
crypto/engine/eng_lib.c
crypto/engine/eng_openssl.c
crypto/engine/eng_table.c
crypto/err/err.c
crypto/evp/bio_b64.c
crypto/evp/bio_enc.c
crypto/evp/bio_ok.c
crypto/evp/digest.c
crypto/evp/evp_enc.c
crypto/evp/evp_pbe.c
crypto/evp/p_lib.c
crypto/evp/pmeth_lib.c
crypto/ex_data.c
crypto/hmac/hm_pmeth.c
crypto/hmac/hmac.c
crypto/jpake/jpake.c
crypto/lhash/lhash.c
crypto/lock.c
crypto/mem_dbg.c
crypto/modes/gcm128.c
crypto/modes/ocb128.c
crypto/objects/Makefile
crypto/objects/o_names.c
crypto/objects/obj_dat.c
crypto/objects/obj_xref.c
crypto/ocsp/ocsp_ht.c
crypto/pqueue/pqueue.c
crypto/rsa/rsa_lib.c
crypto/rsa/rsa_pmeth.c
crypto/srp/srp_vfy.c
crypto/stack/stack.c
crypto/store/str_lib.c
crypto/store/str_mem.c
crypto/store/str_meth.c
crypto/ts/ts_rsp_sign.c
crypto/ts/ts_verify_ctx.c
crypto/txt_db/txt_db.c
crypto/ui/ui_lib.c
crypto/x509/by_dir.c
crypto/x509/x509_lu.c
crypto/x509/x509_trs.c
crypto/x509/x509_vfy.c
crypto/x509/x509_vpm.c
crypto/x509/x_name.c
crypto/x509v3/pcy_cache.c
crypto/x509v3/pcy_data.c
crypto/x509v3/pcy_node.c
crypto/x509v3/pcy_tree.c
crypto/x509v3/v3_asid.c
crypto/x509v3/v3_lib.c
crypto/x509v3/v3_purp.c
crypto/x509v3/v3_scts.c
crypto/x509v3/v3_utl.c
demos/state_machine/state_machine.c
engines/ccgost/gost_pmeth.c
engines/e_capi.c
engines/e_chil.c
engines/e_gmp.c
ssl/bio_ssl.c
ssl/d1_both.c
ssl/d1_lib.c
ssl/record/rec_layer_d1.c
ssl/s3_enc.c
ssl/s3_lib.c
ssl/ssl_cert.c
ssl/ssl_ciph.c
ssl/ssl_conf.c
ssl/ssl_lib.c
ssl/ssl_sess.c
ssl/t1_enc.c
test/Makefile
test/ecdsatest.c
test/ectest.c
test/evp_test.c