[v1,1/1] linux-gen: crypto: check packet length during operation

Message ID 1501502409-30703-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • linux-gen: crypto: check packet length during operation
Related show

Commit Message

Github ODP bot July 31, 2017, noon
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 92 (lumag:crypto-check-len)
 ** https://github.com/Linaro/odp/pull/92
 ** Patch: https://github.com/Linaro/odp/pull/92.patch
 ** Base sha: 79336f5eaee25168a5e4ad7fc0aee07395d4ca1f
 ** Merge commit sha: 67c91fd6b963a3920d8f2cde5b56d76012213a99
 **/
 platform/linux-generic/odp_crypto.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 68fc5658..ab42132a 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -242,6 +242,8 @@  int internal_encrypt(EVP_CIPHER_CTX *ctx, odp_crypto_op_param_t *param)
 	int cipher_len;
 	int ret;
 
+	ODP_ASSERT(in_pos + in_len <= odp_packet_len(pkt));
+
 	while (in_len > 0) {
 		uint32_t seglen = 0; /* GCC */
 		uint8_t *insegaddr = odp_packet_offset(pkt, in_pos,
@@ -297,6 +299,8 @@  int internal_decrypt(EVP_CIPHER_CTX *ctx, odp_crypto_op_param_t *param)
 	int cipher_len;
 	int ret;
 
+	ODP_ASSERT(in_pos + in_len <= odp_packet_len(pkt));
+
 	while (in_len > 0) {
 		uint32_t seglen = 0; /* GCC */
 		uint8_t *insegaddr = odp_packet_offset(pkt, in_pos,