From: Christian Brauner Date: Wed, 26 Sep 2018 12:13:05 +0000 (+0200) Subject: cgfsng: s/25/INTTYPE_TO_STRLEN(pid_t)/g X-Git-Tag: lxc-3.1.0~81^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3650c0c4d54aa09ac8a18a768dbae37d4733801;p=thirdparty%2Flxc.git cgfsng: s/25/INTTYPE_TO_STRLEN(pid_t)/g Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 5d7effcba..7388ad767 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1465,10 +1465,10 @@ __cgfsng_ops static bool __do_cgroup_enter(struct cgroup_ops *ops, pid_t pid, bool monitor) { int len; - char pidstr[25]; + char pidstr[INTTYPE_TO_STRLEN(pid_t)]; - len = snprintf(pidstr, 25, "%d", pid); - if (len < 0 || len >= 25) + len = snprintf(pidstr, sizeof(pidstr), "%d", pid); + if (len < 0 || (size_t)len >= sizeof(pidstr)) return false; for (int i = 0; ops->hierarchies[i]; i++) { @@ -2097,10 +2097,10 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops, const char *name, const char *lxcpath, pid_t pid) { int i, len, ret; - char pidstr[25]; + char pidstr[INTTYPE_TO_STRLEN(pid_t)]; - len = snprintf(pidstr, 25, "%d", pid); - if (len < 0 || len >= 25) + len = snprintf(pidstr, sizeof(pidstr), "%d", pid); + if (len < 0 || (size_t)len >= sizeof(pidstr)) return false; for (i = 0; ops->hierarchies[i]; i++) {