summaryrefslogtreecommitdiffstats
path: root/src/img3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/img3.c')
-rw-r--r--src/img3.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/img3.c b/src/img3.c
index 902bea4..1969ece 100644
--- a/src/img3.c
+++ b/src/img3.c
@@ -155,6 +155,16 @@ img3_file* img3_parse_file(char* data, int size) {
debug("Parsed CERT element\n");
break;
+ case kUnknElement:
+ image->unkn_element = img3_parse_element(&data[data_offset]);
+ if (image->unkn_element == NULL) {
+ error("ERROR: Unable to parse UNKN element\n");
+ img3_free(image);
+ return NULL;
+ }
+ debug("Parsed UNKN element\n");
+ break;
+
default:
error("ERROR: Unknown IMG3 element type\n");
img3_free(image);
@@ -244,6 +254,11 @@ void img3_free(img3_file* image) {
image->cert_element = NULL;
}
+ if (image->unkn_element != NULL) {
+ img3_free_element(image->unkn_element);
+ image->unkn_element = NULL;
+ }
+
free(image);
image = NULL;
}
@@ -336,6 +351,9 @@ int img3_get_data(img3_file* image, char** pdata, int* psize) {
if (image->cert_element != NULL) {
size += image->cert_element->header->full_size;
}
+ if (image->unkn_element != NULL) {
+ size += image->unkn_element->header->full_size;
+ }
char* data = (char*) malloc(size);
if (data == NULL) {
@@ -393,6 +411,10 @@ int img3_get_data(img3_file* image, char** pdata, int* psize) {
memcpy(&data[offset], image->cert_element->data, image->cert_element->header->full_size);
offset += image->cert_element->header->full_size;
}
+ if (image->unkn_element != NULL) {
+ memcpy(&data[offset], image->unkn_element->data, image->unkn_element->header->full_size);
+ offset += image->unkn_element->header->full_size;
+ }
if (offset != size) {
error("ERROR: Incorrectly sized image data\n");