mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-07 12:29:48 +00:00
dm: virtio: use strnlen instead of strlen
Use strnlen instead of strlen to avoid potential security issue. Tracked-On: #1364 Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
9bf5aafebe
commit
b1b3f76db9
@ -40,6 +40,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include "dm.h"
|
#include "dm.h"
|
||||||
#include "pci_core.h"
|
#include "pci_core.h"
|
||||||
@ -326,7 +327,7 @@ virtio_console_announce_port(struct virtio_console_port *port)
|
|||||||
|
|
||||||
event.event = VIRTIO_CONSOLE_PORT_NAME;
|
event.event = VIRTIO_CONSOLE_PORT_NAME;
|
||||||
virtio_console_control_send(port->console, &event, port->name,
|
virtio_console_control_send(port->console, &event, port->name,
|
||||||
strlen(port->name));
|
strnlen(port->name, NAME_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -470,7 +470,8 @@ virtio_input_get_config(struct virtio_input *vi, uint8_t select,
|
|||||||
cfg->u.string);
|
cfg->u.string);
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
cfg->select = VIRTIO_INPUT_CFG_ID_NAME;
|
cfg->select = VIRTIO_INPUT_CFG_ID_NAME;
|
||||||
cfg->size = strlen(cfg->u.string);
|
cfg->size = strnlen(cfg->u.string,
|
||||||
|
sizeof(cfg->u.string));
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user