From: Pavan Deolasee Date: Mon, 4 Feb 2019 12:44:22 +0000 (+0530) Subject: Use a separate buffer to copy GTM options before starting it X-Git-Tag: XL_10_R1_1~9 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=764870b38303f6cdf45ffd08191af87d311fafc2;p=postgres-xl.git Use a separate buffer to copy GTM options before starting it We are seeing an inexplicable failure while testing RPM packages. The GTM proxy fails to start as it tries to access the configuration file in the current working directory instead of the GTM proxy's data directory. Some debug tracing indicates that the problem could be with sprintf trying to copy the source buffer into destination and breaking along the way. So avoid doing that and see if the packages like this. --- diff --git a/src/bin/gtm_ctl/gtm_ctl.c b/src/bin/gtm_ctl/gtm_ctl.c index 9083856f6a..b0f6754bfd 100644 --- a/src/bin/gtm_ctl/gtm_ctl.c +++ b/src/bin/gtm_ctl/gtm_ctl.c @@ -1274,11 +1274,12 @@ main(int argc, char **argv) /* Rebuild option string to include Proxy ID */ if (strcmp(gtm_app, "gtm_proxy") == 0) { - gtmdata_opt = (char *) pg_realloc(gtmdata_opt, strlen(gtmdata_opt) + 9); + char *new_gtmdata_opt = (char *) pg_malloc(strlen(gtmdata_opt) + 9); if (nodename) - sprintf(gtmdata_opt, "%s -i %s ", gtmdata_opt, nodename); + sprintf(new_gtmdata_opt, "%s -i %s ", gtmdata_opt, nodename); else - sprintf(gtmdata_opt, "%s ", gtmdata_opt); + sprintf(new_gtmdata_opt, "%s ", gtmdata_opt); + gtmdata_opt = new_gtmdata_opt; } }