From 64a17dfe35d4f0fdd8658156bf920578b32a497f Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 7 Oct 2020 17:06:36 +0800 Subject: [PATCH 32/34] misc: eliminate a couple of miscellaneous gcc warnings This commit just addresses those warnings shown below. Reference(s): proc/sysinfo.c: In function `getrunners': proc/sysinfo.c:491:26: warning: `%s' directive writing up to 255 bytes into a region of size 26 [-Wformat-overflow=] 491 | sprintf(tbuf, "/proc/%s/stat", ent->d_name); | ^~ https://gitlab.com/procps-ng/procps/-/commit/e3196502784b11c70d6e3c33159403d2f7c118e1 This patch has been modified to fit euler os Signed-off-by: chenmingmin --- proc/sysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/sysinfo.c b/proc/sysinfo.c index 4b2090b..5daa70b 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -488,7 +488,7 @@ static void getrunners(unsigned int *restrict running, unsigned int *restrict bl char c; if (!isdigit(ent->d_name[0])) continue; - sprintf(tbuf, "/proc/%s/stat", ent->d_name); + snprintf(tbuf, sizeof(tbuf), "/proc/%s/stat", ent->d_name); fd = open(tbuf, O_RDONLY, 0); if (fd == -1) continue; -- 2.22.0.windows.1