Fix some places which were doing memcpy(to, from, sizeof(to)); and memset(to, 0, sizeof(to)); Found by the Stanford checker. crypto/deflate.c | 4 ++-- crypto/md4.c | 2 +- crypto/md5.c | 2 +- crypto/tcrypt.c | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff -puN crypto/deflate.c~stanford-crypto-fixes crypto/deflate.c --- 25/crypto/deflate.c~stanford-crypto-fixes 2003-05-14 18:36:01.000000000 -0700 +++ 25-akpm/crypto/deflate.c 2003-05-14 18:36:01.000000000 -0700 @@ -81,7 +81,7 @@ static int deflate_comp_init(struct defl ret = -ENOMEM; goto out; } - memset(stream->workspace, 0, sizeof(stream->workspace)); + memset(stream->workspace, 0, zlib_deflate_workspacesize()); ret = zlib_deflateInit2(stream, DEFLATE_DEF_LEVEL, Z_DEFLATED, -DEFLATE_DEF_WINBITS, DEFLATE_DEF_MEMLEVEL, Z_DEFAULT_STRATEGY); @@ -108,7 +108,7 @@ static int deflate_decomp_init(struct de ret = -ENOMEM; goto out; } - memset(stream->workspace, 0, sizeof(stream->workspace)); + memset(stream->workspace, 0, zlib_inflate_workspacesize()); ret = zlib_inflateInit2(stream, -DEFLATE_DEF_WINBITS); if (ret != Z_OK) { ret = -EINVAL; diff -puN crypto/md4.c~stanford-crypto-fixes crypto/md4.c --- 25/crypto/md4.c~stanford-crypto-fixes 2003-05-14 18:36:01.000000000 -0700 +++ 25-akpm/crypto/md4.c 2003-05-14 18:36:01.000000000 -0700 @@ -215,7 +215,7 @@ static void md4_final(void *ctx, u8 *out md4_transform(mctx->hash, mctx->block); cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(u32)); memcpy(out, mctx->hash, sizeof(mctx->hash)); - memset(mctx, 0, sizeof(mctx)); + memset(mctx, 0, sizeof(*mctx)); } static struct crypto_alg alg = { diff -puN crypto/md5.c~stanford-crypto-fixes crypto/md5.c --- 25/crypto/md5.c~stanford-crypto-fixes 2003-05-14 18:36:01.000000000 -0700 +++ 25-akpm/crypto/md5.c 2003-05-14 18:36:01.000000000 -0700 @@ -210,7 +210,7 @@ static void md5_final(void *ctx, u8 *out md5_transform(mctx->hash, mctx->block); cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(u32)); memcpy(out, mctx->hash, sizeof(mctx->hash)); - memset(mctx, 0, sizeof(mctx)); + memset(mctx, 0, sizeof(*mctx)); } static struct crypto_alg alg = { diff -puN crypto/tcrypt.c~stanford-crypto-fixes crypto/tcrypt.c --- 25/crypto/tcrypt.c~stanford-crypto-fixes 2003-05-14 18:36:01.000000000 -0700 +++ 25-akpm/crypto/tcrypt.c 2003-05-14 18:36:01.000000000 -0700 @@ -113,7 +113,7 @@ test_md5(void) printk("\ntesting md5 across pages\n"); /* setup the dummy buffer first */ - memset(xbuf, 0, sizeof (xbuf)); + memset(xbuf, 0, sizeof(*xbuf)); memcpy(&xbuf[IDX1], "abcdefghijklm", 13); memcpy(&xbuf[IDX2], "nopqrstuvwxyz", 13); @@ -188,7 +188,7 @@ test_hmac_md5(void) printk("\ntesting hmac_md5 across pages\n"); - memset(xbuf, 0, sizeof (xbuf)); + memset(xbuf, 0, sizeof(*xbuf)); memcpy(&xbuf[IDX1], "what do ya want ", 16); memcpy(&xbuf[IDX2], "for nothing?", 12); @@ -267,7 +267,7 @@ test_hmac_sha1(void) printk("\ntesting hmac_sha1 across pages\n"); /* setup the dummy buffer first */ - memset(xbuf, 0, sizeof (xbuf)); + memset(xbuf, 0, sizeof(*xbuf)); memcpy(&xbuf[IDX1], "what do ya want ", 16); memcpy(&xbuf[IDX2], "for nothing?", 12); @@ -450,7 +450,7 @@ test_sha1(void) printk("\ntesting sha1 across pages\n"); /* setup the dummy buffer first */ - memset(xbuf, 0, sizeof (xbuf)); + memset(xbuf, 0, sizeof(*xbuf)); memcpy(&xbuf[IDX1], "abcdbcdecdefdefgefghfghighij", 28); memcpy(&xbuf[IDX2], "hijkijkljklmklmnlmnomnopnopq", 28); @@ -525,7 +525,7 @@ test_sha256(void) printk("\ntesting sha256 across pages\n"); /* setup the dummy buffer first */ - memset(xbuf, 0, sizeof (xbuf)); + memset(xbuf, 0, sizeof(*xbuf)); memcpy(&xbuf[IDX1], "abcdbcdecdefdefgefghfghighij", 28); memcpy(&xbuf[IDX2], "hijkijkljklmklmnlmnomnopnopq", 28); @@ -1027,7 +1027,7 @@ test_des(void) } /* setup the dummy buffer first */ - memset(xbuf, 0, sizeof (xbuf)); + memset(xbuf, 0, sizeof(*xbuf)); xbuf[IDX1] = des_tv[i].plaintext[0]; xbuf[IDX2] = des_tv[i].plaintext[1]; _