BasicASN1Reader: parse type and length as array v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 20 Jun 2021 10:23:50 +0200
branchv_0
changeset 12 243ef6c91dbb
parent 11 8fbe93f78e2b
child 13 d5e2cb9e31f1
BasicASN1Reader: parse type and length as array
src/lib/BasicASN1Reader.h
--- a/src/lib/BasicASN1Reader.h	Sat Jun 19 22:43:00 2021 +0200
+++ b/src/lib/BasicASN1Reader.h	Sun Jun 20 10:23:50 2021 +0200
@@ -18,6 +18,7 @@
 
 #include <memory>
 #include <vector>
+#include <array>
 
 #include "ASN1Reader.h"
 
@@ -43,8 +44,8 @@
 	bool started = false;
 
 	void readNext() {
-		char type;
-		read(&type, 1);
+		std::array<char, 2> typeAndLength;
+		read(typeAndLength.data(), typeAndLength.size());
 		commit();
 
 		if (!started) {
@@ -55,7 +56,8 @@
 		handlers.writeCollectionStart(ASN1ContentHandler::CollectionType::Sequence);
 		handlers.writeNull();
 		handlers.writeBoolean(true);
-		handlers.writeInteger(type);
+		handlers.writeInteger(typeAndLength[0]);
+		handlers.writeInteger(typeAndLength[1]);
 		handlers.writeString(ASN1ContentHandler::StringType::UTF8String, "relational pipes");
 		handlers.writeCollectionEnd();