dm: use snprintf to replace sprintf

Also remove the '\n' from the hugetlb's file name.

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:
Shuo A Liu 2018-12-25 11:45:09 +08:00 committed by wenlingz
parent 4b3ebf69c7
commit 59c6140347
2 changed files with 4 additions and 3 deletions

View File

@ -149,8 +149,9 @@ static int open_hugetlbfs(struct vmctx *ctx, int level)
}
uuid_copy(UUID, ctx->vm_uuid);
sprintf(uuid_str, "%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X%02X%02X\n",
snprintf(uuid_str, sizeof(uuid_str),
"%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X%02X%02X",
UUID[0], UUID[1], UUID[2], UUID[3],
UUID[4], UUID[5], UUID[6], UUID[7],
UUID[8], UUID[9], UUID[10], UUID[11],

View File

@ -636,7 +636,7 @@ smbios_type4_initializer(struct smbios_structure *template_entry,
if (*p++ == '\0')
nstrings++;
}
len = sprintf(*endaddr - 1, "CPU #%d", i) + 1;
len = snprintf(*endaddr - 1, 16, "CPU #%d", i) + 1;
*endaddr += len - 1;
*(*endaddr) = '\0';
(*endaddr)++;