mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Add NULL pointer checks for length in media tag and sector read functions
This commit is contained in:
39
src/read.c
39
src/read.c
@@ -97,6 +97,13 @@ int32_t aaruf_read_media_tag(void *context, uint8_t *data, const int32_t tag, ui
|
|||||||
return AARUF_ERROR_NOT_AARUFORMAT;
|
return AARUF_ERROR_NOT_AARUFORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(length == NULL)
|
||||||
|
{
|
||||||
|
FATAL("Invalid length pointer");
|
||||||
|
TRACE("Exiting aaruf_read_media_tag() = AARUF_ERROR_INCORRECT_DATA_SIZE");
|
||||||
|
return AARUF_ERROR_INCORRECT_DATA_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
const aaruformatContext *ctx = context;
|
const aaruformatContext *ctx = context;
|
||||||
|
|
||||||
// Not a libaaruformat context
|
// Not a libaaruformat context
|
||||||
@@ -269,6 +276,14 @@ int32_t aaruf_read_sector(void *context, const uint64_t sector_address, bool neg
|
|||||||
|
|
||||||
ctx = context;
|
ctx = context;
|
||||||
|
|
||||||
|
if(length == NULL)
|
||||||
|
{
|
||||||
|
FATAL("Invalid length pointer");
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_read_sector() = AARUF_ERROR_INCORRECT_DATA_SIZE");
|
||||||
|
return AARUF_ERROR_INCORRECT_DATA_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
// Not a libaaruformat context
|
// Not a libaaruformat context
|
||||||
if(ctx->magic != AARU_MAGIC)
|
if(ctx->magic != AARU_MAGIC)
|
||||||
{
|
{
|
||||||
@@ -640,6 +655,14 @@ int32_t aaruf_read_track_sector(void *context, uint8_t *data, const uint64_t sec
|
|||||||
|
|
||||||
aaruformatContext *ctx = context;
|
aaruformatContext *ctx = context;
|
||||||
|
|
||||||
|
if(length == NULL)
|
||||||
|
{
|
||||||
|
FATAL("Invalid length pointer");
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_read_track_sector() = AARUF_ERROR_INCORRECT_DATA_SIZE");
|
||||||
|
return AARUF_ERROR_INCORRECT_DATA_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
// Not a libaaruformat context
|
// Not a libaaruformat context
|
||||||
if(ctx->magic != AARU_MAGIC)
|
if(ctx->magic != AARU_MAGIC)
|
||||||
{
|
{
|
||||||
@@ -793,6 +816,14 @@ int32_t aaruf_read_sector_long(void *context, const uint64_t sector_address, boo
|
|||||||
|
|
||||||
ctx = context;
|
ctx = context;
|
||||||
|
|
||||||
|
if(length == NULL)
|
||||||
|
{
|
||||||
|
FATAL("Invalid length pointer");
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_read_sector_long() = AARUF_ERROR_INCORRECT_DATA_SIZE");
|
||||||
|
return AARUF_ERROR_INCORRECT_DATA_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
// Not a libaaruformat context
|
// Not a libaaruformat context
|
||||||
if(ctx->magic != AARU_MAGIC)
|
if(ctx->magic != AARU_MAGIC)
|
||||||
{
|
{
|
||||||
@@ -1290,6 +1321,14 @@ int32_t aaruf_read_sector_tag(const void *context, const uint64_t sector_address
|
|||||||
|
|
||||||
ctx = context;
|
ctx = context;
|
||||||
|
|
||||||
|
if(length == NULL)
|
||||||
|
{
|
||||||
|
FATAL("Invalid length pointer");
|
||||||
|
|
||||||
|
TRACE("Exiting aaruf_read_sector_tag() = AARUF_ERROR_INCORRECT_DATA_SIZE");
|
||||||
|
return AARUF_ERROR_INCORRECT_DATA_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
// Not a libaaruformat context
|
// Not a libaaruformat context
|
||||||
if(ctx->magic != AARU_MAGIC)
|
if(ctx->magic != AARU_MAGIC)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user