1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-30 18:22:50 -05:00

psftp: use cmdline_arg_to_filename for batch files.

On Windows, this means they can use non-CP_ACP characters. Also it has
the side effect of cloning the filename out of the CmdlineArgList,
which makes it still valid after cmdline_arg_list_free (oops).
This commit is contained in:
Simon Tatham 2024-11-28 21:20:23 +00:00
parent d4e848a962
commit ebe2453446

10
psftp.c
View File

@ -2393,7 +2393,7 @@ static void do_sftp_cleanup(void)
} }
} }
int do_sftp(int mode, int modeflags, const char *batchfile) int do_sftp(int mode, int modeflags, Filename *batchfile)
{ {
FILE *fp; FILE *fp;
int ret; int ret;
@ -2417,9 +2417,9 @@ int do_sftp(int mode, int modeflags, const char *batchfile)
break; break;
} }
} else { } else {
fp = fopen(batchfile, "r"); fp = f_open(batchfile, "r", false);
if (!fp) { if (!fp) {
printf("Fatal: unable to open %s\n", batchfile); printf("Fatal: unable to open %s\n", filename_to_str(batchfile));
return 1; return 1;
} }
ret = 0; ret = 0;
@ -2800,7 +2800,7 @@ int psftp_main(CmdlineArgList *arglist)
int mode = 0; int mode = 0;
int modeflags = 0; int modeflags = 0;
bool sanitise_stderr = true; bool sanitise_stderr = true;
const char *batchfile = NULL; Filename *batchfile = NULL;
sk_init(); sk_init();
@ -2845,7 +2845,7 @@ int psftp_main(CmdlineArgList *arglist)
version(); version();
} else if (strcmp(argstr, "-b") == 0 && nextarg) { } else if (strcmp(argstr, "-b") == 0 && nextarg) {
mode = 1; mode = 1;
batchfile = cmdline_arg_to_str(nextarg); batchfile = cmdline_arg_to_filename(nextarg);
arglistpos++; arglistpos++;
} else if (strcmp(argstr, "-bc") == 0) { } else if (strcmp(argstr, "-bc") == 0) {
modeflags = modeflags | 1; modeflags = modeflags | 1;