From 32a6b1c277bc825be22083eb9286622f65dd562c Mon Sep 17 00:00:00 2001
From: Yihang Li <liyihang9@h-partners.com>
Date: Mon, 4 Aug 2025 11:34:47 +0800
Subject: [PATCH 7/9] sysSentry: Fix Security Scan Warning

driver inclusion
category: feature
bugzilla: https://gitee.com/src-openeuler/sysSentry/issues/ID1UOY
CVE: NA

----------------------------------------------------------------------

Fix Security Scan Warning:
a. There should be one space between the comment symbol and the comment
content.
b. Use snprintf instead of sprintf.

Signed-off-by: Yihang Li <liyihang9@h-partners.com>
Signed-off-by: Qizhi Zhang <zhangqizhi3@h-partners.com>
---
 src/sentryPlugins/soc_ring_sentry/tc_ring_one.c | 4 ++--
 src/sentryPlugins/soc_ring_sentry/tc_ring_one.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/sentryPlugins/soc_ring_sentry/tc_ring_one.c b/src/sentryPlugins/soc_ring_sentry/tc_ring_one.c
index 5101070..ea8fb34 100755
--- a/src/sentryPlugins/soc_ring_sentry/tc_ring_one.c
+++ b/src/sentryPlugins/soc_ring_sentry/tc_ring_one.c
@@ -48,7 +48,7 @@ struct tc_ring_one_config {
     int                    sys_core_total;          // 系统核总数
     int                    scan_bit;                // 扫描的bit
     int                    err_flag;                 // 错误计数
-    int                    numa_node;               //系统numa总数
+    int                    numa_node;               // 系统numa总数
 };
 
 #define TC_RING_ONE_BLOCK_SIZE                      0x10000
@@ -119,7 +119,7 @@ static uintptr_t vaddr_to_phys(uintptr_t vaddr)
     int fd;
 
     offset = vaddr / page_size * (sizeof(pinfo));
-    sprintf(page_map_name, "/proc/%d/pagemap", pid);
+    snprintf(page_map_name, sizeof(page_map_name), "/proc/%d/pagemap", pid);
     fd = open(page_map_name, O_RDONLY);
     if (fd < 0) {
         logging_error("Failed to open %s\n", page_map_name);
diff --git a/src/sentryPlugins/soc_ring_sentry/tc_ring_one.h b/src/sentryPlugins/soc_ring_sentry/tc_ring_one.h
index d5a25ee..5e93a56 100755
--- a/src/sentryPlugins/soc_ring_sentry/tc_ring_one.h
+++ b/src/sentryPlugins/soc_ring_sentry/tc_ring_one.h
@@ -34,4 +34,4 @@
  */
 int tc_ring_one_main(uint64_t mem_size, uint64_t loop_cnt, uint64_t delay, uint64_t err_handle, bool *blacklist, size_t core_num);
 
-#endif/*__TC_RING_ONE_H__*/
\ No newline at end of file
+#endif /*__TC_RING_ONE_H__*/
-- 
2.33.0