mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-15 05:49:17 +00:00
dm: refine the check of return value of snprintf
int snprintf(char *str, size_t size, const char *format, ...) The functions snprintf() write at most size bytes (including the terminating null byte('\0')) to str. only when returned value of snprintf is non-negative and less than size, the string has been completely written. Tracked-On: #4109 Signed-off-by: Gao Junhao <junhao.gao@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
@@ -2383,8 +2383,8 @@ pci_ahci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts, int atapi)
|
||||
sizeof(ahci_dev->port[p].ident),
|
||||
"ACRN--%02X%02X-%02X%02X-%02X%02X", digest[0],
|
||||
digest[1], digest[2], digest[3], digest[4], digest[5]);
|
||||
if (rc > sizeof(ahci_dev->port[p].ident))
|
||||
WPRINTF("%s: digest is longer than ident\n", __func__);
|
||||
if (rc >= sizeof(ahci_dev->port[p].ident) || rc < 0)
|
||||
WPRINTF("%s: digest number is invalid!\n", __func__);
|
||||
|
||||
/*
|
||||
* Allocate blockif request structures and add them
|
||||
|
Reference in New Issue
Block a user