mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Fix reading dump hardware entries.
This commit is contained in:
64
src/open.c
64
src/open.c
@@ -878,8 +878,15 @@ void* aaruf_open(const char* filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data = (uint8_t*)malloc(ctx->dumpHardwareHeader.length);
|
data = (uint8_t*)malloc(ctx->dumpHardwareHeader.length);
|
||||||
if(data != NULL)
|
|
||||||
|
if(data == NULL)
|
||||||
{
|
{
|
||||||
|
memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader));
|
||||||
|
fprintf(stderr,
|
||||||
|
"libaaruformat: Could not allocate memory for dump hardware block, continuing...\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
readBytes = fread(data, 1, ctx->dumpHardwareHeader.length, ctx->imageStream);
|
readBytes = fread(data, 1, ctx->dumpHardwareHeader.length, ctx->imageStream);
|
||||||
|
|
||||||
if(readBytes == ctx->dumpHardwareHeader.length)
|
if(readBytes == ctx->dumpHardwareHeader.length)
|
||||||
@@ -902,8 +909,7 @@ void* aaruf_open(const char* filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
fseek(ctx->imageStream, -readBytes, SEEK_CUR);
|
fseek(ctx->imageStream, -(long)readBytes, SEEK_CUR);
|
||||||
}
|
|
||||||
|
|
||||||
ctx->dumpHardwareEntriesWithData = (DumpHardwareEntriesWithData*)malloc(
|
ctx->dumpHardwareEntriesWithData = (DumpHardwareEntriesWithData*)malloc(
|
||||||
sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries);
|
sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries);
|
||||||
@@ -927,7 +933,7 @@ void* aaruf_open(const char* filepath)
|
|||||||
|
|
||||||
if(readBytes != sizeof(DumpHardwareEntry))
|
if(readBytes != sizeof(DumpHardwareEntry))
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareHeader.entries = e + (uint16_t)1;
|
ctx->dumpHardwareHeader.entries = e;
|
||||||
fprintf(stderr, "libaaruformat: Could not read dump hardware block entry, continuing...\n");
|
fprintf(stderr, "libaaruformat: Could not read dump hardware block entry, continuing...\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -935,11 +941,13 @@ void* aaruf_open(const char* filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].manufacturer =
|
ctx->dumpHardwareEntriesWithData[e].manufacturer =
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].manufacturer != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].manufacturer != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].manufacturer,
|
ctx->dumpHardwareEntriesWithData[e]
|
||||||
|
.manufacturer[ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].manufacturer,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
@@ -958,11 +966,13 @@ void* aaruf_open(const char* filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.modelLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.modelLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].model =
|
ctx->dumpHardwareEntriesWithData[e].model =
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].model != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].model != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].model,
|
ctx->dumpHardwareEntriesWithData[e]
|
||||||
|
.model[ctx->dumpHardwareEntriesWithData[e].entry.modelLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].model,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.modelLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.modelLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
@@ -981,11 +991,13 @@ void* aaruf_open(const char* filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].revision =
|
ctx->dumpHardwareEntriesWithData[e].revision =
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].revision != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].revision != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].revision,
|
ctx->dumpHardwareEntriesWithData[e]
|
||||||
|
.revision[ctx->dumpHardwareEntriesWithData[e].entry.revisionLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].revision,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.revisionLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.revisionLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
@@ -1004,11 +1016,13 @@ void* aaruf_open(const char* filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].firmware =
|
ctx->dumpHardwareEntriesWithData[e].firmware =
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].firmware != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].firmware != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].firmware,
|
ctx->dumpHardwareEntriesWithData[e]
|
||||||
|
.firmware[ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].firmware,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
@@ -1027,11 +1041,13 @@ void* aaruf_open(const char* filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.serialLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.serialLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].serial =
|
ctx->dumpHardwareEntriesWithData[e].serial =
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].serial != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].serial != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].serial,
|
ctx->dumpHardwareEntriesWithData[e]
|
||||||
|
.serial[ctx->dumpHardwareEntriesWithData[e].entry.serialLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].serial,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.serialLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.serialLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
@@ -1050,11 +1066,13 @@ void* aaruf_open(const char* filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].softwareName =
|
ctx->dumpHardwareEntriesWithData[e].softwareName =
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].softwareName != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].softwareName != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].softwareName,
|
ctx->dumpHardwareEntriesWithData[e]
|
||||||
|
.softwareName[ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareName,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
@@ -1073,11 +1091,13 @@ void* aaruf_open(const char* filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].softwareVersion =
|
ctx->dumpHardwareEntriesWithData[e].softwareVersion =
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].softwareVersion != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].softwareVersion != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].softwareVersion,
|
ctx->dumpHardwareEntriesWithData[e]
|
||||||
|
.softwareVersion[ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareVersion,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
@@ -1095,12 +1115,14 @@ void* aaruf_open(const char* filepath)
|
|||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem =
|
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem = (uint8_t*)malloc(
|
||||||
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength);
|
ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength + 1);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(&ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem,
|
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem
|
||||||
|
[ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength] = 0;
|
||||||
|
readBytes = fread(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem,
|
||||||
1,
|
1,
|
||||||
ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength,
|
ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength,
|
||||||
ctx->imageStream);
|
ctx->imageStream);
|
||||||
|
|||||||
Reference in New Issue
Block a user