[Kernel/VFS] Add maximum size for thumbnails read from headers
This commit is contained in:
parent
7bf3d257ef
commit
79081ca272
|
@ -118,9 +118,10 @@ X_RESULT FolderContentPackage::GetThumbnail(std::vector<uint8_t>* buffer) {
|
|||
sizeof(vfs::StfsHeader));
|
||||
if (map) {
|
||||
auto* header = (vfs::StfsHeader*)map->data();
|
||||
buffer->resize(header->metadata.thumbnail_size);
|
||||
memcpy(buffer->data(), header->metadata.thumbnail,
|
||||
header->metadata.thumbnail_size);
|
||||
uint32_t thumb_size = std::min((uint32_t)header->metadata.thumbnail_size,
|
||||
xe::vfs::XContentMetadata::kThumbLengthV1);
|
||||
buffer->resize(thumb_size);
|
||||
memcpy(buffer->data(), header->metadata.thumbnail, thumb_size);
|
||||
result = X_ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -171,14 +172,15 @@ X_RESULT StfsContentPackage::GetThumbnail(std::vector<uint8_t>* buffer) {
|
|||
if (!device_inited_) {
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
buffer->resize(header_.metadata.thumbnail_size);
|
||||
memcpy(buffer->data(), header_.metadata.thumbnail,
|
||||
header_.metadata.thumbnail_size);
|
||||
uint32_t thumb_size = std::min((uint32_t)header_.metadata.thumbnail_size,
|
||||
xe::vfs::XContentMetadata::kThumbLengthV1);
|
||||
buffer->resize(thumb_size);
|
||||
memcpy(buffer->data(), header_.metadata.thumbnail, thumb_size);
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
X_RESULT StfsContentPackage::SetThumbnail(std::vector<uint8_t> buffer) {
|
||||
return X_ERROR_FUNCTION_FAILED; // can't write to STFS headers right now
|
||||
return X_ERROR_FUNCTION_FAILED; // can't write to STFS package right now
|
||||
}
|
||||
|
||||
X_RESULT StfsContentPackage::Delete() {
|
||||
|
|
|
@ -167,6 +167,9 @@ enum class XContentVolumeType : uint32_t {
|
|||
};
|
||||
|
||||
struct XContentMetadata {
|
||||
static const uint32_t kThumbLength = 0x3D00;
|
||||
static const uint32_t kThumbLengthV1 = 0x4000;
|
||||
|
||||
xe::be<XContentType> content_type;
|
||||
xe::be<uint32_t> metadata_version;
|
||||
xe::be<uint64_t> content_size;
|
||||
|
|
Loading…
Reference in New Issue