[CRIU] [PATCH] Fix --cpu-cap option parsing, v2
Cyrill Gorcunov
gorcunov at gmail.com
Mon Jan 26 09:05:26 PST 2015
On Mon, Jan 26, 2015 at 07:17:22PM +0300, Cyrill Gorcunov wrote:
> Manage to forgot to increase pointer by length
> of the words parsed.
>
> Reported-by: Mark O'Neill <mao at tumblingdice.co.uk>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Pick up attached instead please, sorry for noise.
-------------- next part --------------
>From b9ebf5d22853519f5b620121a83d49aa473af642 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Mon, 26 Jan 2015 19:16:52 +0300
Subject: [PATCH] Fix --cpu-cap option parsing, v2
Manage to forgot to increase pointer by length
of the words parsed.
Reported-by: Mark O'Neill <mao at tumblingdice.co.uk>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
crtools.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/crtools.c b/crtools.c
index 1f1f5501cb6a..fafcb011d988 100644
--- a/crtools.c
+++ b/crtools.c
@@ -105,26 +105,36 @@ static int parse_cpu_cap(struct cr_options *opts, const char *optarg)
return 0;
}
- for (; *optarg; optarg++) {
+ while (*optarg) {
if (optarg[0] == '^') {
inverse = !inverse;
+ optarg++;
continue;
} else if (optarg[0] == ',') {
inverse = false;
+ optarg++;
continue;
}
- if (!strncmp(optarg, "fpu", 3))
+ if (!strncmp(optarg, "fpu", 3)) {
____cpu_set_cap(opts, CPU_CAP_FPU, inverse);
- else if (!strncmp(optarg, "all", 3))
+ optarg += 3;
+ } else if (!strncmp(optarg, "all", 3)) {
____cpu_set_cap(opts, CPU_CAP_ALL, inverse);
- else if (!strncmp(optarg, "none", 3))
- ____cpu_set_cap(opts, CPU_CAP_NONE, inverse);
- else if (!strncmp(optarg, "cpu", 3))
+ optarg += 3;
+ } else if (!strncmp(optarg, "none", 4)) {
+ if (inverse)
+ opts->cpu_cap = CPU_CAP_ALL;
+ else
+ opts->cpu_cap = CPU_CAP_NONE;
+ optarg += 4;
+ } else if (!strncmp(optarg, "cpu", 3)) {
____cpu_set_cap(opts, CPU_CAP_CPU, inverse);
- else if (!strncmp(optarg, "ins", 3))
+ optarg += 3;
+ } else if (!strncmp(optarg, "ins", 3)) {
____cpu_set_cap(opts, CPU_CAP_INS, inverse);
- else
+ optarg += 3;
+ } else
goto Esyntax;
}
#undef ____cpu_set_cap
--
1.9.3
More information about the CRIU
mailing list