aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@amd.com>2010-09-10 18:57:47 +0100
committerAndre Przywara <andre.przywara@amd.com>2010-09-10 18:57:47 +0100
commita48b2967f975fcd8e1edf8a9cc9f1ef004992825 (patch)
tree3ea50c7af6fe559d3883e9abe40d9a0ff9605b6c /tools
parent5ab30725b1736b3af47ad911b800a8fbcbd6a112 (diff)
downloadxen-a48b2967f975fcd8e1edf8a9cc9f1ef004992825.tar.gz
xen-a48b2967f975fcd8e1edf8a9cc9f1ef004992825.tar.bz2
xen-a48b2967f975fcd8e1edf8a9cc9f1ef004992825.zip
xl: Fix adding additional config cmdline parameters
When checking the size of the buffer we hold for additional config parameters passed on the command line we should take the size of the to-be-added string into account. While at it, rework the implementation to be cleaner and safer. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/libxl/xl_cmdimpl.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 6e2fce786d..547b2f6fa5 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3179,21 +3179,17 @@ int main_create(int argc, char **argv)
}
}
- memset(extra_config, 0, sizeof(extra_config));
- while (optind < argc) {
- if ((p = strchr(argv[optind], '='))) {
- if (strlen(extra_config) + 1 < sizeof(extra_config)) {
- if (strlen(extra_config))
- strcat(extra_config, "\n");
- strcat(extra_config, argv[optind]);
- }
+ extra_config[0] = '\0';
+ for (p = extra_config; optind < argc; optind++) {
+ if (strchr(argv[optind], '=') != NULL) {
+ p += snprintf(p, sizeof(extra_config) - (p - extra_config),
+ "%s\n", argv[optind]);
} else if (!filename) {
filename = argv[optind];
} else {
help("create");
return 2;
}
- optind++;
}
memset(&dom_info, 0, sizeof(dom_info));