[CRIU] [PATCH 01/13] namespaces: __get_ns_id -- Use safe snprintf
Cyrill Gorcunov
gorcunov at openvz.org
Fri Oct 20 00:59:32 MSK 2017
Namespace descriptors are not promised to have
constant short names, so just to be on a safe
side.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/namespaces.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 56dd2bcb4d9c..5c46976410e4 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -470,7 +470,7 @@ static unsigned int __get_ns_id(int pid, struct ns_desc *nd, bool alternative,
if (proc_dir < 0)
return 0;
- sprintf(ns_path, "ns/%s", !alternative ? nd->str : nd->alt_str);
+ snprintf(ns_path, sizeof(ns_path), "ns/%s", !alternative ? nd->str : nd->alt_str);
if (fstatat(proc_dir, ns_path, &st, 0)) {
if (errno == ENOENT) {
--
2.7.5
More information about the CRIU
mailing list