From a935a65b77e0e635049365aa04c1e7909cb60f9b Mon Sep 17 00:00:00 2001 From: Craig Small Date: Wed, 20 Dec 2017 21:37:01 +1100 Subject: [PATCH] library: Explicit about task ID string length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the following error by stating the task ID can only be 10 characters wide, as it is an integer. proc/readproc.c: In function ‘simple_nexttid’: proc/readproc.c:1185:46: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 41 and 51 [-Wformat-truncation=] snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name); ^~ proc/readproc.c:1185:3: note: ‘snprintf’ output between 14 and 279 bytes into a destination of size 64 snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- proc/readproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/readproc.c b/proc/readproc.c index 68619229..1fe7ce04 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -1182,7 +1182,7 @@ static int simple_nexttid(PROCTAB *restrict const PT, const proc_t *restrict con t->tid = strtoul(ent->d_name, NULL, 10); t->tgid = p->tgid; //t->ppid = p->ppid; // cover for kernel behavior? we want both actually...? - snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name); + snprintf(path, PROCPATHLEN, "/proc/%d/task/%.10s", p->tgid, ent->d_name); return 1; }