summaryrefslogtreecommitdiff
path: root/egg
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2010-07-21 16:26:08 -0500
committerStef Walter <stef@memberwebs.com>2010-07-26 12:12:35 +0200
commit2964e1671c3f472055fe5070f5b746d5389cfbc0 (patch)
treef58db3a04dc37650fdb564451a43c1b5762b4e19 /egg
parent7ebeea19e62f2a2fcd79596a798bcc8238fb1b54 (diff)
downloadgnome-keyring-2964e1671c3f472055fe5070f5b746d5389cfbc0.tar.gz
[egg] Fix problems building on 32-bit.
Make encoding of unsigned longs adapt to long size.
Diffstat (limited to 'egg')
-rw-r--r--egg/egg-asn1x.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/egg/egg-asn1x.c b/egg/egg-asn1x.c
index cfe51a3b..9f0d5d3e 100644
--- a/egg/egg-asn1x.c
+++ b/egg/egg-asn1x.c
@@ -1983,29 +1983,25 @@ anode_read_integer_as_ulong (GNode *node, Atlv *tlv, gulong *value)
static gboolean
anode_write_integer_ulong (gulong value, guchar *data, gsize *n_data)
{
- guchar buf[8];
- gint bytes;
-
- buf[0] = (value >> 56) & 0xFF;
- buf[1] = (value >> 48) & 0xFF;
- buf[2] = (value >> 40) & 0xFF;
- buf[3] = (value >> 32) & 0xFF;
- buf[4] = (value >> 24) & 0xFF;
- buf[5] = (value >> 16) & 0xFF;
- buf[6] = (value >> 8) & 0xFF;
- buf[7] = (value >> 0) & 0xFF;
-
- for (bytes = 7; bytes >= 0; --bytes)
+ guchar buf[sizeof (gulong)];
+ gint bytes, i, off;
+
+ for (i = 0; i < sizeof (ulong); ++i) {
+ off = sizeof (ulong) - (i + 1);
+ buf[i] = (value >> (off * 8)) & 0xFF;
+ }
+
+ for (bytes = sizeof (gulong) - 1; bytes >= 0; --bytes)
if (!buf[bytes])
break;
- bytes = 8 - (bytes + 1);
+ bytes = sizeof (gulong) - (bytes + 1);
if (bytes == 0)
bytes = 1;
if (data) {
g_assert (*n_data >= bytes);
- memcpy (data, buf + (8 - bytes), bytes);
+ memcpy (data, buf + (sizeof (gulong) - bytes), bytes);
}
*n_data = bytes;
return TRUE;