[01/13] namespaces: __get_ns_id -- Use safe snprintf

Submitted by Cyrill Gorcunov on Oct. 19, 2017, 9:59 p.m.

Details

Message ID 1508450384-29215-2-git-send-email-gorcunov@openvz.org
State New
Series "Clean up image format and fix anon shmem bits strip"
Headers show

Commit Message

Cyrill Gorcunov Oct. 19, 2017, 9:59 p.m.
Namespace descriptors are not promised to have
constant short names, so just to be on a safe
side.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 criu/namespaces.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

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) {