Skip to content

Commit eff44fb

Browse files
fyin1wenlingz
authored andcommitted
build fix: fix build issue with latest gcc for blkrescan
With latest gcc version 9.1.1 20190506 from Clear Linux, we hit following build issue in blkrescan code: In function ‘strncpy’, inlined from ‘blkrescan_vm’ at acrn_vm_ops.c:468:2: /usr/include/bits/string_fortified.h:106:10: error: \ ‘__builtin___strncpy_chk’ specified bound depends on the length \ of the source argument [-Werror=stringop-overflow=] When calling strncpy, the size n should be set to max dest size instead of src size. Tracked-On: #3096 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Yan, Like <like.yan@intel.com>
1 parent c7da397 commit eff44fb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/acrn-manager/acrn_vm_ops.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ int blkrescan_vm(const char *vmname, char *devargs)
465465
req.magic = MNGR_MSG_MAGIC;
466466
req.msgid = DM_BLKRESCAN;
467467
req.timestamp = time(NULL);
468-
strncpy(req.data.devargs, devargs, strlen(devargs)+1);
468+
strncpy(req.data.devargs, devargs, PARAM_LEN - 1);
469+
req.data.devargs[PARAM_LEN - 1] = '\0';
469470

470471
send_msg(vmname, &req, &ack);
471472

0 commit comments

Comments
 (0)