mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2026-02-04 05:24:56 +00:00
Guard against writes of too big sectors.
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
#define AARUF_ERROR_TAPE_FILE_NOT_FOUND (-28) ///< Requested tape file number not present in image.
|
||||
#define AARUF_ERROR_TAPE_PARTITION_NOT_FOUND (-29) ///< Requested tape partition not present in image.
|
||||
#define AARUF_ERROR_METADATA_NOT_PRESENT (-30) ///< Requested metadata not present in image.
|
||||
#define AARUF_ERROR_INVALID_SECTOR_LENGTH (-31) ///< Sector length is too big.
|
||||
/** @} */
|
||||
|
||||
/** \name Non-fatal sector status codes (non-negative)
|
||||
|
||||
@@ -147,6 +147,14 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_
|
||||
return AARUF_ERROR_SECTOR_OUT_OF_BOUNDS;
|
||||
}
|
||||
|
||||
if(length > USHRT_MAX)
|
||||
{
|
||||
FATAL("Sector length too large");
|
||||
|
||||
TRACE("Exiting aaruf_write_sector() = AARUF_ERROR_INVALID_SECTOR_LENGTH");
|
||||
return AARUF_ERROR_INVALID_SECTOR_LENGTH;
|
||||
}
|
||||
|
||||
if(length > ctx->header.biggestSectorSize) ctx->header.biggestSectorSize = (uint16_t)length;
|
||||
|
||||
if(!ctx->rewinded)
|
||||
|
||||
Reference in New Issue
Block a user