diff options
author | cem <cem@FreeBSD.org> | 2016-05-26 19:29:29 +0000 |
---|---|---|
committer | cem <cem@FreeBSD.org> | 2016-05-26 19:29:29 +0000 |
commit | 444253bba579f26af746a0fbf42b89b8f44298a0 (patch) | |
tree | a3f8dd317ab9b8bf2071cc3dc88766e3294342a7 /sys/kern | |
parent | 6aac4cff86e423c72bc1e352d3435843185b5977 (diff) | |
download | FreeBSD-src-444253bba579f26af746a0fbf42b89b8f44298a0.zip FreeBSD-src-444253bba579f26af746a0fbf42b89b8f44298a0.tar.gz |
crypto routines: Hint minimum buffer sizes to the compiler
Use the C99 'static' keyword to hint to the compiler IVs and output digest
sizes. The keyword informs the compiler of the minimum valid size for a given
array. Obviously not every pointer can be validated (i.e., the compiler can
produce false negative but not false positive reports).
No functional change. No ABI change.
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/md4c.c | 6 | ||||
-rw-r--r-- | sys/kern/md5c.c | 8 |
2 files changed, 5 insertions, 9 deletions
diff --git a/sys/kern/md4c.c b/sys/kern/md4c.c index 84a294a..7cfb84b 100644 --- a/sys/kern/md4c.c +++ b/sys/kern/md4c.c @@ -164,9 +164,7 @@ MD4_CTX *context; /* context */ /* MD4 finalization. Ends an MD4 message-digest operation, writing the the message digest and zeroizing the context. */ -void MD4Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD4_CTX *context; /* context */ +void MD4Final (unsigned char digest[static 16], MD4_CTX *context) { /* Do padding */ MD4Pad (context); @@ -176,7 +174,7 @@ MD4_CTX *context; /* context */ /* Zeroize sensitive information. */ - bzero((POINTER)context, sizeof (*context)); + bzero(context, sizeof (*context)); } /* MD4 basic transformation. Transforms state based on block. diff --git a/sys/kern/md5c.c b/sys/kern/md5c.c index 50e2022..3e0165a 100644 --- a/sys/kern/md5c.c +++ b/sys/kern/md5c.c @@ -217,18 +217,16 @@ MD5Pad (MD5_CTX *context) */ void -MD5Final (digest, context) - unsigned char digest[16]; - MD5_CTX *context; +MD5Final(unsigned char digest[static MD5_DIGEST_LENGTH], MD5_CTX *context) { /* Do padding. */ MD5Pad (context); /* Store state in digest */ - Encode (digest, context->state, 16); + Encode (digest, context->state, MD5_DIGEST_LENGTH); /* Zeroize sensitive information. */ - memset ((void *)context, 0, sizeof (*context)); + memset (context, 0, sizeof (*context)); } /* MD5 basic transformation. Transforms state based on block. */ |