Use a separate buffer to copy GTM options before starting it
authorPavan Deolasee <[email protected]>
Mon, 4 Feb 2019 12:44:22 +0000 (18:14 +0530)
committerPavan Deolasee <[email protected]>
Mon, 4 Feb 2019 12:44:22 +0000 (18:14 +0530)
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.

src/bin/gtm_ctl/gtm_ctl.c

index 9083856f6ab363584f823bbddceb7510a5ac85f9..b0f6754bfdc34a5bf4ba7c7ee4bf305f68b092e7 100644 (file)
@@ -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;
                }
        }