mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Read CICM XML metadata block.
This commit is contained in:
@@ -62,6 +62,8 @@ typedef struct dicformatContext
|
|||||||
unsigned char *metadataBlock;
|
unsigned char *metadataBlock;
|
||||||
TracksHeader tracksHeader;
|
TracksHeader tracksHeader;
|
||||||
TrackEntry *trackEntries;
|
TrackEntry *trackEntries;
|
||||||
|
CicmMetadataBlock cicmBlockHeader;
|
||||||
|
unsigned char *cicmBlock;
|
||||||
} dicformatContext;
|
} dicformatContext;
|
||||||
|
|
||||||
typedef struct dataLinkedList
|
typedef struct dataLinkedList
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ int close(void *context)
|
|||||||
|
|
||||||
dicformatContext *ctx = context;
|
dicformatContext *ctx = context;
|
||||||
|
|
||||||
// TODO: Cast this field without casting the whole structure, as this can buffer overlow
|
// TODO: Cast this field without casting the whole structure, as this can buffer overflow
|
||||||
// Not a libdicformat context
|
// Not a libdicformat context
|
||||||
if(ctx->magic != DIC_MAGIC)
|
if(ctx->magic != DIC_MAGIC)
|
||||||
{
|
{
|
||||||
@@ -93,6 +93,7 @@ int close(void *context)
|
|||||||
|
|
||||||
free(ctx->metadataBlock);
|
free(ctx->metadataBlock);
|
||||||
free(ctx->trackEntries);
|
free(ctx->trackEntries);
|
||||||
|
free(ctx->cicmBlock);
|
||||||
|
|
||||||
free(context);
|
free(context);
|
||||||
|
|
||||||
|
|||||||
40
src/open.c
40
src/open.c
@@ -570,8 +570,44 @@ void *open(const char *filepath)
|
|||||||
// TODO: ImageInfo
|
// TODO: ImageInfo
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CicmBlock:
|
// CICM XML metadata block
|
||||||
// TODO
|
case CicmBlock:readBytes = fread(&ctx->cicmBlockHeader, sizeof(CicmMetadataBlock), 1, ctx->imageStream);
|
||||||
|
|
||||||
|
if(readBytes != sizeof(CicmMetadataBlock))
|
||||||
|
{
|
||||||
|
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
|
||||||
|
fprintf(stderr, "libdicformat: Could not read CICM XML metadata header, continuing...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ctx->cicmBlockHeader.identifier != CicmBlock)
|
||||||
|
{
|
||||||
|
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
|
||||||
|
fprintf(stderr,
|
||||||
|
"libdicformat: Incorrect identifier for data block at position %"PRIu64"",
|
||||||
|
idxEntries[i].offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->cicmBlock = malloc(ctx->cicmBlockHeader.length);
|
||||||
|
|
||||||
|
if(ctx->cicmBlock == NULL)
|
||||||
|
{
|
||||||
|
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
|
||||||
|
fprintf(stderr,
|
||||||
|
"libdicformat: Could not allocate memory for CICM XML metadata block, continuing...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
readBytes = fread(ctx->cicmBlock, ctx->cicmBlockHeader.length, 1, ctx->imageStream);
|
||||||
|
|
||||||
|
if(readBytes != ctx->metadataBlockHeader.blockSize)
|
||||||
|
{
|
||||||
|
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
|
||||||
|
free(ctx->cicmBlock);
|
||||||
|
fprintf(stderr, "libdicformat: Could not read CICM XML metadata block, continuing...");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "libdicformat: Found CICM XML metadata block %"PRIu64".", idxEntries[i].offset);
|
||||||
break;
|
break;
|
||||||
case DumpHardwareBlock:
|
case DumpHardwareBlock:
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user