aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-l2tp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-05-09 16:35:45 -0700
committerGuy Harris <guy@alum.mit.edu>2015-05-09 23:36:11 +0000
commitacf7985f7377806e23d7ec9daa14a3a6886a51c7 (patch)
tree3c46c8ceb05fc7feee052c138c437f83f5381a53 /epan/dissectors/packet-l2tp.c
parentbb89e7724220098e7b7fba5d31daf0d916b2d553 (diff)
Define the SHA-1 digest length in wsutil/sha1.h and use it.
Hopefully that'll make it a little easier to make sure that we're not overflowing arrays. Change-Id: I770df045ef9a45fd486c1271ea424b3334bb39d2 Reviewed-on: https://code.wireshark.org/review/8370 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-l2tp.c')
-rw-r--r--epan/dissectors/packet-l2tp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/epan/dissectors/packet-l2tp.c b/epan/dissectors/packet-l2tp.c
index 8cff05f654..ad66e5c4b7 100644
--- a/epan/dissectors/packet-l2tp.c
+++ b/epan/dissectors/packet-l2tp.c
@@ -782,7 +782,6 @@ static dissector_handle_t l2tp_ip_handle;
#define L2TP_HMAC_SHA1 1
#define L2TP_HMAC_MD5_KEY_LEN 16
#define L2TP_HMAC_MD5_DIGEST_LEN 16
-#define L2TP_HMAC_SHA1_DIGEST_LEN 20
typedef struct l2tpv3_conversation {
address lcce1;
@@ -897,7 +896,7 @@ static void sha1_hmac_digest(l2tpv3_tunnel_t *tunnel,
packet_info *pinfo,
guint8 digest[20])
{
- guint8 zero[L2TP_HMAC_SHA1_DIGEST_LEN];
+ guint8 zero[SHA1_DIGEST_LEN];
sha1_hmac_context ms;
int remainder;
int offset = 0;
@@ -921,7 +920,7 @@ static void sha1_hmac_digest(l2tpv3_tunnel_t *tunnel,
sha1_hmac_update(&ms, tvb_get_ptr(tvb, 0, idx + 1 - offset), idx + 1 - offset);
/* Message digest is calculated with an empty message digest field */
- memset(zero, 0, L2TP_HMAC_SHA1_DIGEST_LEN);
+ memset(zero, 0, SHA1_DIGEST_LEN);
sha1_hmac_update(&ms, zero, avp_len - 1);
remainder = length - (idx + avp_len);
sha1_hmac_update(&ms, tvb_get_ptr(tvb, idx + avp_len, remainder), remainder);
@@ -936,7 +935,7 @@ static int check_control_digest(l2tpv3_tunnel_t *tunnel,
int msg_type,
packet_info *pinfo)
{
- guint8 digest[L2TP_HMAC_SHA1_DIGEST_LEN];
+ guint8 digest[SHA1_DIGEST_LEN];
if (!tunnel)
return 1;
@@ -950,7 +949,7 @@ static int check_control_digest(l2tpv3_tunnel_t *tunnel,
md5_hmac_digest(tunnel, tvb, length, idx, avp_len, msg_type, pinfo, digest);
break;
case L2TP_HMAC_SHA1:
- if ((avp_len - 1) != L2TP_HMAC_SHA1_DIGEST_LEN)
+ if ((avp_len - 1) != SHA1_DIGEST_LEN)
return -1;
sha1_hmac_digest(tunnel, tvb, length, idx, avp_len, msg_type, pinfo, digest);
break;