Skip to content

Commit 59c6140

Browse files
Shuo A Liuwenlingz
authored andcommitted
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>
1 parent 4b3ebf6 commit 59c6140

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

devicemodel/core/hugetlb.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ static int open_hugetlbfs(struct vmctx *ctx, int level)
149149
}
150150

151151
uuid_copy(UUID, ctx->vm_uuid);
152-
sprintf(uuid_str, "%02X%02X%02X%02X%02X%02X%02X%02X"
153-
"%02X%02X%02X%02X%02X%02X%02X%02X\n",
152+
snprintf(uuid_str, sizeof(uuid_str),
153+
"%02X%02X%02X%02X%02X%02X%02X%02X"
154+
"%02X%02X%02X%02X%02X%02X%02X%02X",
154155
UUID[0], UUID[1], UUID[2], UUID[3],
155156
UUID[4], UUID[5], UUID[6], UUID[7],
156157
UUID[8], UUID[9], UUID[10], UUID[11],

devicemodel/core/smbiostbl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ smbios_type4_initializer(struct smbios_structure *template_entry,
636636
if (*p++ == '\0')
637637
nstrings++;
638638
}
639-
len = sprintf(*endaddr - 1, "CPU #%d", i) + 1;
639+
len = snprintf(*endaddr - 1, 16, "CPU #%d", i) + 1;
640640
*endaddr += len - 1;
641641
*(*endaddr) = '\0';
642642
(*endaddr)++;

0 commit comments

Comments
 (0)