[lxc-devel] [patch] fix improper null termination

Ryousei Takano takano-ryousei at aist.go.jp
Fri Jan 29 08:44:35 UTC 2010


Hi Daniel,

This patch correctly terminates the string returned by readlink(2) with a NULL charactor.

Thanks,
Ryousei
---
 src/lxc/start.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index 032fdf6..684a700 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -191,7 +191,7 @@ static int fdname(int fd, char *name, size_t size)
 
 	len = readlink(path, name, size);
 	if (len >  0)
-		path[len] = '\0';
+		name[len] = '\0';
 
 	return (len <= 0) ? -1 : 0;
 }
@@ -244,7 +244,7 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf)
 		goto out_free;
 	}
 
-	if (console_init(conf->console, sizeof(conf->console))) {
+	if (console_init(conf->console, sizeof(conf->console) - 1)) {
 		ERROR("failed to initialize the console");
 		goto out_aborting;
 	}
-- 
1.5.5.6






More information about the lxc-devel mailing list