From b6756865f3aaaa700515f041350c0f1ed39f397f Mon Sep 17 00:00:00 2001
From: fujuntang <fujuntang@smartai.com>
Date: 星期六, 18 九月 2021 19:38:49 +0800
Subject: [PATCH] Add the null terminated flag.

---
 src/bh_api.cpp |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/bh_api.cpp b/src/bh_api.cpp
index 635fe95..312b203 100644
--- a/src/bh_api.cpp
+++ b/src/bh_api.cpp
@@ -123,49 +123,49 @@
 #if defined(PRO_DE_SERIALIZE)
     if (_input.proc_id != NULL) {
       count = strlen(_input.proc_id) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1) ? (MAX_STR_LEN - 1) : count;
       strncpy(pData.proc_id, _input.proc_id, min);
     }
 
     if (_input.name != NULL) {
       count = strlen(_input.name) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1)? (MAX_STR_LEN -1) : count;
       strncpy(pData.name, _input.name, min); 
     }
 
     if (_input.public_info != NULL) {
       count = strlen(_input.public_info) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1)? (MAX_STR_LEN - 1) : count;
       strncpy(pData.public_info, _input.public_info, min);
     }
  
     if (_input.private_info != NULL) {
       count = strlen(_input.private_info) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1)? (MAX_STR_LEN - 1): count;
       strncpy(pData.private_info, _input.private_info, min);
     }
 #else 
     if (strlen((const char *)(((ProcInfo *)proc_info)->proc_id)) > 0) {
       count = strlen((const char *)(((ProcInfo *)proc_info)->proc_id)) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1) ? (MAX_STR_LEN - 1): count;
       strncpy(pData.proc_id, ((ProcInfo *)proc_info)->proc_id, min);
     }
 
     if (strlen((const char *)(((ProcInfo *)proc_info)->name)) > 0) {
       count = strlen((const char *)(((ProcInfo *)proc_info)->name)) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1) ? (MAX_STR_LEN - 1) : count;
       strncpy(pData.name, ((ProcInfo *)proc_info)->name, min); 
     }
 
     if (strlen((const char *)(((ProcInfo *)proc_info)->public_info)) > 0) {
       count = strlen((const char *)(((ProcInfo *)proc_info)->public_info)) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1) ? (MAX_STR_LEN - 1) : count;
       strncpy(pData.public_info, ((ProcInfo *)proc_info)->public_info, min);
     }
  
     if (strlen((const char *)(((ProcInfo *)proc_info)->private_info)) > 0) {
       count = strlen((const char *)(((ProcInfo *)proc_info)->private_info)) + 1;
-      min = count > MAX_STR_LEN ? MAX_STR_LEN : count;
+      min = count > (MAX_STR_LEN - 1) ? (MAX_STR_LEN - 1) : count;
       strncpy(pData.private_info, ((ProcInfo *)proc_info)->private_info, min);
     }
 #endif 

--
Gitblit v1.8.0