mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 18:14:53 +00:00
tools: acrn-manager: refine the usage of api 'snprintf'
Return value check for snprintf function Tracked-On: #1254 Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com> Acked-by: Yan, Like <like.yan@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com> Reviewed-by: Kaige Fu <kaige.fu@intel.com>
This commit is contained in:
@@ -219,14 +219,18 @@ static void acrnd_run_vm(char *name)
|
||||
{
|
||||
char log_path[128] = {};
|
||||
|
||||
snprintf(log_path, sizeof(log_path) -1, ACRND_LOG_FMT, name);
|
||||
unlink(log_path);
|
||||
stdin = freopen(log_path, "w+", stdin);
|
||||
stdout = freopen(log_path, "w+", stdout);
|
||||
stderr = freopen(log_path, "w+", stderr);
|
||||
fflush(stdin);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
if (snprintf(log_path, sizeof(log_path) -1, ACRND_LOG_FMT, name)
|
||||
>= sizeof(log_path) -1) {
|
||||
printf("WARN: log path is truncated\n");
|
||||
} else {
|
||||
unlink(log_path);
|
||||
stdin = freopen(log_path, "w+", stdin);
|
||||
stdout = freopen(log_path, "w+", stdout);
|
||||
stderr = freopen(log_path, "w+", stderr);
|
||||
fflush(stdin);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
start_vm(name);
|
||||
printf("%s exited!\n", name);
|
||||
|
||||
Reference in New Issue
Block a user