Skip to content
Snippets Groups Projects
Commit 6b7f37b9 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Merge branch 'patches/bug10075' into 8.0

* patches/bug10075:
  Standards.ASN1.Decode: Set error mode on Stdio.Buffer.
  Prevent infinite loops when decoding incomplete data.
parents afe56639 c4a1aa48
No related branches found
No related tags found
Loading
...@@ -110,6 +110,7 @@ protected array(int) read_identifier(Stdio.Buffer data) ...@@ -110,6 +110,7 @@ protected array(int) read_identifier(Stdio.Buffer data)
constructed, tag, len); constructed, tag, len);
data = [object(Stdio.Buffer)]data->read_buffer(len); data = [object(Stdio.Buffer)]data->read_buffer(len);
data->set_error_mode(1);
program(.Types.Object) p = types[ .Types.make_combined_tag(cls, tag) ]; program(.Types.Object) p = types[ .Types.make_combined_tag(cls, tag) ];
...@@ -234,7 +235,7 @@ mapping(int:program(.Types.Object)) universal_types = ...@@ -234,7 +235,7 @@ mapping(int:program(.Types.Object)) universal_types =
mapping(int:program(.Types.Object))|void types) mapping(int:program(.Types.Object))|void types)
{ {
types = types ? universal_types+types : universal_types; types = types ? universal_types+types : universal_types;
Stdio.Buffer buf = Stdio.Buffer(data); Stdio.Buffer buf = Stdio.Buffer(data)->set_error_mode(1);
.Types.Object ret = der_decode(buf, types); .Types.Object ret = der_decode(buf, types);
if( sizeof(buf) ) return 0; if( sizeof(buf) ) return 0;
return ret; return ret;
......
...@@ -20,6 +20,12 @@ test_do( add_constant("P", lambda(object o) ...@@ -20,6 +20,12 @@ test_do( add_constant("P", lambda(object o)
test_eval_error(Standards.ASN1.Decode.simple_der_decode("")) test_eval_error(Standards.ASN1.Decode.simple_der_decode(""))
test_eval_error(Standards.ASN1.Decode.simple_der_decode(""))
test_eval_error(Standards.ASN1.Decode.secure_der_decode(""))
test_eval_error(Standards.ASN1.Decode.simple_der_decode(String.hex2string("a2184515521e4c5d26f05590543c696ca2bd04b7754a18107d7f62744fbcb3a52ee80de3dca53339c3f6b2196afe3c540adfeb92686029f2")))
test_eval_error(Standards.ASN1.Decode.secure_der_decode(String.hex2string("a2184515521e4c5d26f05590543c696ca2bd04b7754a18107d7f62744fbcb3a52ee80de3dca53339c3f6b2196afe3c540adfeb92686029f2")))
define(test_decode,[[ define(test_decode,[[
test_eq(P(Standards.ASN1.Decode.simple_der_decode(String.hex2string($1-" "))),$2) test_eq(P(Standards.ASN1.Decode.simple_der_decode(String.hex2string($1-" "))),$2)
test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string($1-" "))->get_der(), test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string($1-" "))->get_der(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment