summaryrefslogtreecommitdiff
path: root/egg
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-12-13 14:52:12 +0100
committerStef Walter <stefw@collabora.co.uk>2011-12-13 14:52:12 +0100
commit1b5dfd5d5bf2e53eb8c1edb53605bc93443e0f73 (patch)
treeea1e838f8c81d30c53e65d48bb2079ac4d4a55b2 /egg
parent567cf5f4ecf914a2b949ae2014d0a27088697f65 (diff)
downloadgcr-1b5dfd5d5bf2e53eb8c1edb53605bc93443e0f73.tar.gz
egg: Check that bytes are valid when they come into ASN.1
Diffstat (limited to 'egg')
-rw-r--r--egg/egg-asn1x.c10
1 files changed, 10 insertions, 0 deletions
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 */