summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-05-24 12:47:31 -0700
committerJeremy Allison <jra@samba.org>2011-05-24 22:57:16 +0200
commite719dfd4dc178f001a5f804fb1ac4e587574415f (patch)
tree4c6b8b4da5ef102718c6ae633adec8089656b855 /lib
parentede98c0e5190bf59461703629d5a4742ad8e044f (diff)
downloadsamba-e719dfd4dc178f001a5f804fb1ac4e587574415f.tar.gz
samba-e719dfd4dc178f001a5f804fb1ac4e587574415f.tar.bz2
samba-e719dfd4dc178f001a5f804fb1ac4e587574415f.zip
Fix our asn.1 parser to handle negative numbers.
Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Tue May 24 22:57:16 CEST 2011 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r--lib/util/asn1.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index b716da63c0..c23bf65b8d 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -885,10 +885,19 @@ bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo
bool asn1_read_implicit_Integer(struct asn1_data *data, int *i)
{
uint8_t b;
+ bool first_byte = true;
*i = 0;
while (!data->has_error && asn1_tag_remaining(data)>0) {
if (!asn1_read_uint8(data, &b)) return false;
+ if (first_byte) {
+ if (b & 0x80) {
+ /* Number is negative.
+ Set i to -1 for sign extend. */
+ *i = -1;
+ }
+ first_byte = false;
+ }
*i = (*i << 8) + b;
}
return !data->has_error;