dm: use strncpy to replace strcpy
Tracked-On: #2133 Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
parent
b3ad44d4c1
commit
4b3ebf69c7
|
@ -318,7 +318,7 @@ acrn_sw_load_bzimage(struct vmctx *ctx)
|
|||
ctx->bsp_regs.vcpu_id = 0;
|
||||
|
||||
if (with_bootargs) {
|
||||
strcpy(ctx->baseaddr + BOOTARGS_LOAD_OFF(ctx), get_bootargs());
|
||||
strncpy(ctx->baseaddr + BOOTARGS_LOAD_OFF(ctx), get_bootargs(), STR_LEN);
|
||||
printf("SW_LOAD: bootargs copied to guest 0x%lx\n",
|
||||
BOOTARGS_LOAD_OFF(ctx));
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ acrn_sw_load_vsbl(struct vmctx *ctx)
|
|||
vsbl_para->acpi_table_size = get_acpi_table_length();
|
||||
|
||||
if (with_bootargs) {
|
||||
strcpy(ctx->baseaddr + BOOTARGS_OFF(ctx), get_bootargs());
|
||||
strncpy(ctx->baseaddr + BOOTARGS_OFF(ctx), get_bootargs(), STR_LEN);
|
||||
vsbl_para->bootargs_address = BOOTARGS_OFF(ctx);
|
||||
} else {
|
||||
vsbl_para->bootargs_address = 0;
|
||||
|
|
|
@ -122,7 +122,7 @@ vm_create(const char *name, uint64_t req_buf)
|
|||
ctx->fd = devfd;
|
||||
ctx->lowmem_limit = 2 * GB;
|
||||
ctx->name = (char *)(ctx + 1);
|
||||
strcpy(ctx->name, name);
|
||||
strncpy(ctx->name, name, strnlen(name, PATH_MAX) + 1);
|
||||
|
||||
/* Set trusty enable flag */
|
||||
if (trusty_enabled)
|
||||
|
|
|
@ -347,7 +347,7 @@ connect_hdcp_daemon()
|
|||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, HDCP_SDK_SOCKET_PATH);
|
||||
strncpy(addr.sun_path, HDCP_SDK_SOCKET_PATH, sizeof(addr.sun_path));
|
||||
|
||||
ret = connect(fd, &addr, sizeof(struct sockaddr_un));
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -653,19 +653,19 @@ virtio_net_tap_open(char *devname)
|
|||
return -1;
|
||||
}
|
||||
|
||||
strcpy(devname, ifr.ifr_name);
|
||||
strncpy(devname, ifr.ifr_name, IFNAMSIZ);
|
||||
return tunfd;
|
||||
}
|
||||
|
||||
static void
|
||||
virtio_net_tap_setup(struct virtio_net *net, char *devname)
|
||||
{
|
||||
char tbuf[80 + 5]; /* room for "acrn_" prefix */
|
||||
char tbuf[IFNAMSIZ];
|
||||
int vhost_fd = -1;
|
||||
int rc;
|
||||
|
||||
rc = snprintf(tbuf, strnlen(devname, 79) + 6, "acrn_%s", devname);
|
||||
if (rc < 0 || rc >= 85) /* give warning if error or truncation happens */
|
||||
rc = snprintf(tbuf, IFNAMSIZ, "acrn_%s", devname);
|
||||
if (rc < 0 || rc >= IFNAMSIZ) /* give warning if error or truncation happens */
|
||||
WPRINTF(("Fail to set tap device name %s\n", tbuf));
|
||||
|
||||
net->virtio_net_rx = virtio_net_tap_rx;
|
||||
|
|
|
@ -50,7 +50,7 @@ int acrn_parse_vtpm2(char *arg)
|
|||
sock_path = calloc(len + 1, 1);
|
||||
if (!sock_path)
|
||||
return -1;
|
||||
strcpy(sock_path, value);
|
||||
strncpy(sock_path, value, len + 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue