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