Skip to content

Commit 34e16fd

Browse files
committed
sshfs-win: fix sshfs invocation
1 parent 1512332 commit 34e16fd

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

sshfs-win.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,24 @@ static void usage(void)
5151
exit(2);
5252
}
5353

54+
static void concat_argv(char *dst[], char *src[])
55+
{
56+
for (; 0 != *dst; dst++)
57+
;
58+
for (; 0 != (*dst = *src); dst++, src++)
59+
;
60+
}
61+
5462
static int do_cmd(int argc, char *argv[])
5563
{
56-
execve(sshfs, argv + 1, sshfs_environ);
64+
char *sshfs_argv[256] =
65+
{
66+
sshfs, 0,
67+
};
68+
69+
concat_argv(sshfs_argv, argv + 1);
70+
71+
execve(sshfs, sshfs_argv, sshfs_environ);
5772
return 1;
5873
}
5974

@@ -163,13 +178,9 @@ static int do_svc(int argc, char *argv[])
163178
{
164179
sshfs, SSHFS_ARGS, idmap, volpfx, portopt, remote, argv[2], 0,
165180
};
166-
int i, j;
167181

168-
for (j = 0; 0 != sshfs_argv[j]; j++)
169-
;
170-
for (i = 4; argc > i; i++, j++)
171-
sshfs_argv[j] = argv[i];
172-
sshfs_argv[j] = 0;
182+
if (4 <= argc)
183+
concat_argv(sshfs_argv, argv + 4);
173184

174185
execve(sshfs, sshfs_argv, sshfs_environ);
175186
return 1;

0 commit comments

Comments
 (0)