aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-10-08 12:06:11 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-10-08 12:06:11 +0200
commitd672e0fa1d4502603a064e390fba21691735a6d3 (patch)
tree5c5601912b71091d5d8948d62dbb503310a76a63
parent513fd31d16e527ecebc86911bd33ee73d6d16f9f (diff)
[HICN-303] Fixed reading size of authentication header which might have caused a bufferoverflow
Change-Id: I46ae0539a51c9a2a11d8acfe4146470f2d4fa21d Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
-rw-r--r--lib/src/compat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/src/compat.c b/lib/src/compat.c
index 633037a0f..38c78d99a 100644
--- a/lib/src/compat.c
+++ b/lib/src/compat.c
@@ -182,8 +182,10 @@ hicn_packet_get_header_length (hicn_format_t format, const hicn_header_t * h,
int is_ipv4 = _is_ipv4 (format);
int is_ipv6 = _is_ipv6 (format);
// The signature payload is expressed as number of 32 bits words
- *header_length += (is_ah * is_ipv4) * (h->v4ah.ah.payloadlen) << 2;
- *header_length += (is_ah * is_ipv6) * (h->v6ah.ah.payloadlen) << 2;
+ if (is_ah && is_ipv4)
+ *header_length += (h->v4ah.ah.payloadlen) << 2;
+ else if(is_ah && is_ipv6)
+ *header_length += (h->v6ah.ah.payloadlen) << 2;
return HICN_LIB_ERROR_NONE;
}