[CRIU] [PATCH] clear opts before setting

Ruslan Kuprieiev kupruser at gmail.com
Sun Oct 13 13:46:51 PDT 2013


Hi!

Lets clear the opts, before resetting them in cr-service, so old options won't affect the new ones.
We don't do some "free"s here, because we have only char pointers and they point only to constant strings.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 cr-service.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/cr-service.c b/cr-service.c
index 771944c..ecc39dd 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -97,6 +97,11 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 	socklen_t ids_len = sizeof(struct ucred);
 	char images_dir_path[PATH_MAX];
 
+	/* clear opts from old data */
+	(void)memset(&opts, 0, sizeof(opts));
+	INIT_LIST_HEAD(&opts.veth_pairs);
+	INIT_LIST_HEAD(&opts.scripts);
+
 	if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
 		pr_perror("Can't get socket options.");
 		return -1;
@@ -140,6 +145,8 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 	/* checking flags from client */
 	if (req->has_leave_running && req->leave_running)
 		opts.final_state = TASK_ALIVE;
+	else
+		opts.final_state = TASK_DEAD;
 
 	if (!req->has_pid) {
 		req->has_pid = true;
-- 
1.8.1.2



More information about the CRIU mailing list