From eb6beefdfb9b854f7dd761830d50713e1ab45627 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 23 Aug 2023 07:25:50 +0000
Subject: [PATCH 08/10] !2126 do not judge the snprintf result of hostname * do
 not judge the snprintf result of hostname

---
 src/daemon/executor/container_cb/execution_network.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/daemon/executor/container_cb/execution_network.c b/src/daemon/executor/container_cb/execution_network.c
index 09aadd9b..95cfcce3 100644
--- a/src/daemon/executor/container_cb/execution_network.c
+++ b/src/daemon/executor/container_cb/execution_network.c
@@ -924,10 +924,10 @@ static int create_default_hostname(const char *id, const char *rootpath, bool sh
             ret = gethostname(hostname, sizeof(hostname));
         } else {
             // max length of hostname from ID is 12 + '\0'
+            // the purpose is to truncate the first 12 bits of id,
+            // nret is 64, no need to judge
             nret = snprintf(hostname, 13, "%s", id);
-            if (nret < 0 || (size_t)nret >= 13) {
-                ret = -1;
-            }
+            ret = nret < 0 ? 1 : 0;
         }
         if (ret != 0) {
             ERROR("Create hostname error");
-- 
2.25.1

