|
15 | 15 | staticintappend_option(char*buf,size_tbuf_size,size_tdst,charconst*src)
|
16 | 16 | {
|
17 | 17 | size_tlen=strlen(src);
|
18 |
| -if (dst+len+1 >=buf_size) { |
| 18 | +if (dst+len+3 >=buf_size) { |
19 | 19 | fprintf(stderr,"Too long command line\n");
|
20 | 20 | exit(EXIT_FAILURE);
|
21 | 21 | }
|
22 |
| -buf[dst]=' '; |
23 |
| -memcpy(&buf[dst+1],src,len); |
24 |
| -returndst+len+1; |
| 22 | +buf[dst++]=' '; |
| 23 | +if (strchr(src,' ')!=NULL) {/* need quotes */ |
| 24 | +buf[dst++]='\''; |
| 25 | +memcpy(&buf[dst],src,len); |
| 26 | +dst+=len; |
| 27 | +buf[dst++]='\''; |
| 28 | +}else { |
| 29 | +memcpy(&buf[dst],src,len); |
| 30 | +dst+=len; |
| 31 | +} |
| 32 | +returndst; |
25 | 33 | }
|
26 | 34 |
|
27 | 35 | staticintsplit_options(intargc,char*argv[],intmax_options,char*options)
|
@@ -93,7 +101,7 @@ int remote_execute(int argc, char* argv[], bool listen)
|
93 | 101 | ssh_argv[ssh_argc++]=instance_config.remote.ssh_config;
|
94 | 102 | }
|
95 | 103 | if (instance_config.remote.ssh_options!=NULL) {
|
96 |
| -ssh_argc=split_options(ssh_argc,ssh_argv,MAX_CMDLINE_OPTIONS,instance_config.remote.ssh_options); |
| 104 | +ssh_argc=split_options(ssh_argc,ssh_argv,MAX_CMDLINE_OPTIONS,pg_strdup(instance_config.remote.ssh_options)); |
97 | 105 | }
|
98 | 106 | ssh_argv[ssh_argc++]=instance_config.remote.host;
|
99 | 107 | ssh_argv[ssh_argc++]=cmd;
|
|