[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] xl: Fix adding additional config cmdline parameters
# HG changeset patch # User Andre Przywara <andre.przywara@xxxxxxx> # Date 1284141467 -3600 # Node ID 862a07d67ea3a589da79a418941347c62a8aa604 # Parent a9f272d4ab4f121e223b9533b5c9d3489f733597 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@xxxxxxx> Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/xl_cmdimpl.c | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-) diff -r a9f272d4ab4f -r 862a07d67ea3 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Fri Sep 10 18:57:28 2010 +0100 +++ b/tools/libxl/xl_cmdimpl.c Fri Sep 10 18:57:47 2010 +0100 @@ -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)); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |