mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 23:13:26 +00:00
Fix string may be truncated issue with using snprintf
New compiler options introduced by commit
519c4285cf
will cause DM compile failure
which caused by warnings from some snprintf usage might be truncated.
Expanding the string buffer to make compiler happy.
v3: change format string
v2: Address comment from Hao, shrink bident string size to satify
tname length in blockif_open.
Signed-off-by: Rusty Lynch <rusty.lynch@intel.com>
Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
This commit is contained in:
parent
383bc5100a
commit
4c96a58601
@ -2312,10 +2312,11 @@ pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx,
|
||||
static int
|
||||
pci_ahci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts, int atapi)
|
||||
{
|
||||
char bident[sizeof("XX:XX:XX")];
|
||||
char bident[16];
|
||||
struct blockif_ctxt *bctxt;
|
||||
struct pci_ahci_vdev *ahci_dev;
|
||||
int ret, slots, p;
|
||||
int ret, slots;
|
||||
uint8_t p;
|
||||
MD5_CTX mdctx;
|
||||
u_char digest[16];
|
||||
char *next, *next2;
|
||||
@ -2365,7 +2366,7 @@ pci_ahci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts, int atapi)
|
||||
* Attempt to open the backing image. Use the PCI slot/func
|
||||
* and the port number for the identifier string.
|
||||
*/
|
||||
snprintf(bident, sizeof(bident), "%d:%d:%d", dev->slot,
|
||||
snprintf(bident, sizeof(bident), "%02x:%02x:%02x", dev->slot,
|
||||
dev->func, p);
|
||||
bctxt = blockif_open(opts, bident);
|
||||
if (bctxt == NULL) {
|
||||
|
@ -285,7 +285,7 @@ virtio_blk_notify(void *vdev, struct virtio_vq_info *vq)
|
||||
static int
|
||||
virtio_blk_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
{
|
||||
char bident[sizeof("XX:X:X")];
|
||||
char bident[16];
|
||||
struct blockif_ctxt *bctxt;
|
||||
MD5_CTX mdctx;
|
||||
u_char digest[16];
|
||||
|
Loading…
Reference in New Issue
Block a user