From 776d90d801ee253157f9de90416a93bfc7bfd55e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 31 Aug 2004 06:21:14 +0000 Subject: r2122: merge from trunk (-r 2120): Fix bug found by Love H?\195?\182rnquist ?\195?\133strand: asn1_write_Integer needs to push stuff little endian. (This used to be commit 79bee828fbb70e71ad3fbd45758bcc7775ea977b) --- source4/libcli/util/asn1.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source4') diff --git a/source4/libcli/util/asn1.c b/source4/libcli/util/asn1.c index 6f613f398b..756a33f77d 100644 --- a/source4/libcli/util/asn1.c +++ b/source4/libcli/util/asn1.c @@ -107,15 +107,23 @@ BOOL asn1_pop_tag(ASN1_DATA *data) return True; } +static void push_int_littleendian(ASN1_DATA *data, int i) +{ + uint8_t lowest = i & 0xFF; + + i = i >> 8; + if (i != 0) + push_int_littleendian(data, i); + + asn1_write_uint8(data, lowest); +} + /* write an integer */ BOOL asn1_write_Integer(ASN1_DATA *data, int i) { if (!asn1_push_tag(data, ASN1_INTEGER)) return False; - do { - asn1_write_uint8(data, i); - i = i >> 8; - } while (i); + push_int_littleendian(data, i); return asn1_pop_tag(data); } -- cgit