From 1b5dfd5d5bf2e53eb8c1edb53605bc93443e0f73 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 13 Dec 2011 14:52:12 +0100 Subject: [PATCH] egg: Check that bytes are valid when they come into ASN.1 --- egg/egg-asn1x.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/egg/egg-asn1x.c b/egg/egg-asn1x.c index fc80d8f..cea8dad 100644 --- a/egg/egg-asn1x.c +++ b/egg/egg-asn1x.c @@ -1214,6 +1214,8 @@ egg_asn1x_decode_no_validate (GNode *asn, egg_asn1x_clear (asn); dat = egg_bytes_get_data (data); + g_return_val_if_fail (dat != NULL, FALSE); + size = egg_bytes_get_size (data); if (!anode_decode_tlv_for_data (dat, dat + size, &tlv)) return anode_failure (asn, "content is not encoded properly"); @@ -1597,6 +1599,8 @@ anode_encoder_unsigned (gpointer user_data, */ p = egg_bytes_get_data (value); + g_return_val_if_fail (p != NULL, FALSE); + sign = !!(p[0] & 0x80); if (sign) { g_assert (n_data > 1); @@ -2853,6 +2857,8 @@ egg_asn1x_take_integer_as_raw (GNode *node, /* Make sure the integer is properly encoded in twos complement*/ p = egg_bytes_get_data (value); + g_return_if_fail (p != NULL); + sign = !!(p[0] & 0x80); if (sign) { g_warning ("integer in egg_asn1x_set_integer_as_raw is not two's complement"); @@ -2885,6 +2891,8 @@ egg_asn1x_take_integer_as_usg (GNode *node, /* Make sure the integer is properly encoded in twos complement*/ p = egg_bytes_get_data (value); + g_return_if_fail (p != NULL); + sign = !!(p[0] & 0x80); len = egg_bytes_get_size (value); @@ -2948,6 +2956,8 @@ egg_asn1x_set_element_raw (GNode *node, memset (&dtlv, 0, sizeof (dtlv)); data = egg_bytes_get_data (element); + g_return_val_if_fail (data != NULL, FALSE); + size = egg_bytes_get_size (element); /* Decode the beginning TLV */ -- 2.7.4