mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
virtio-devices: fs: cap the tag copy length
The caller shouldn't pass in an &str that's too long. This is a precaution if something goes wrong in the caller. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
11c593e3b9
commit
101cfb9650
@ -399,7 +399,12 @@ impl Fs {
|
||||
// Create virtio-fs device configuration.
|
||||
let mut config = VirtioFsConfig::default();
|
||||
let tag_bytes_slice = tag.as_bytes();
|
||||
config.tag[..tag_bytes_slice.len()].copy_from_slice(tag_bytes_slice);
|
||||
let len = if tag_bytes_slice.len() < config.tag.len() {
|
||||
tag_bytes_slice.len()
|
||||
} else {
|
||||
config.tag.len()
|
||||
};
|
||||
config.tag[..len].copy_from_slice(tag_bytes_slice[..len].as_ref());
|
||||
config.num_request_queues = req_num_queues as u32;
|
||||
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user