1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-27 16:57:08 -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;
int ret;
@ -2417,9 +2417,9 @@ int do_sftp(int mode, int modeflags, const char *batchfile)
break;
}
} else {
fp = fopen(batchfile, "r");
fp = f_open(batchfile, "r", false);
if (!fp) {
printf("Fatal: unable to open %s\n", batchfile);
printf("Fatal: unable to open %s\n", filename_to_str(batchfile));
return 1;
}
ret = 0;
@ -2800,7 +2800,7 @@ int psftp_main(CmdlineArgList *arglist)
int mode = 0;
int modeflags = 0;
bool sanitise_stderr = true;
const char *batchfile = NULL;
Filename *batchfile = NULL;
sk_init();
@ -2845,7 +2845,7 @@ int psftp_main(CmdlineArgList *arglist)
version();
} else if (strcmp(argstr, "-b") == 0 && nextarg) {
mode = 1;
batchfile = cmdline_arg_to_str(nextarg);
batchfile = cmdline_arg_to_filename(nextarg);
arglistpos++;
} else if (strcmp(argstr, "-bc") == 0) {
modeflags = modeflags | 1;