зеркало из https://github.com/github/putty.git
Oops - fix another segfault in that -L and -R code
[originally from svn r1412]
This commit is contained in:
Родитель
14ab514528
Коммит
9d814fd26e
5
plink.c
5
plink.c
|
@ -447,7 +447,7 @@ int main(int argc, char **argv)
|
||||||
strncpy(cfg.username, username, sizeof(cfg.username));
|
strncpy(cfg.username, username, sizeof(cfg.username));
|
||||||
cfg.username[sizeof(cfg.username) - 1] = '\0';
|
cfg.username[sizeof(cfg.username) - 1] = '\0';
|
||||||
} else if ((!strcmp(p, "-L") || !strcmp(p, "-R")) && argc > 1) {
|
} else if ((!strcmp(p, "-L") || !strcmp(p, "-R")) && argc > 1) {
|
||||||
char *fwd, *ptr;
|
char *fwd, *ptr, *q;
|
||||||
int i=0;
|
int i=0;
|
||||||
--argc, fwd = *++argv;
|
--argc, fwd = *++argv;
|
||||||
ptr = extra_portfwd;
|
ptr = extra_portfwd;
|
||||||
|
@ -460,7 +460,8 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
ptr[0] = p[1]; /* insert a 'L' or 'R' at the start */
|
ptr[0] = p[1]; /* insert a 'L' or 'R' at the start */
|
||||||
strncpy(ptr+1, fwd, sizeof(extra_portfwd) - i);
|
strncpy(ptr+1, fwd, sizeof(extra_portfwd) - i);
|
||||||
ptr[strcspn(ptr, ":")] = '\t'; /* replace first : with \t */
|
q = strchr(ptr, ':');
|
||||||
|
if (q) *q = '\t'; /* replace first : with \t */
|
||||||
ptr[strlen(ptr)+1] = '\000'; /* append two '\000' */
|
ptr[strlen(ptr)+1] = '\000'; /* append two '\000' */
|
||||||
extra_portfwd[sizeof(extra_portfwd) - 1] = '\0';
|
extra_portfwd[sizeof(extra_portfwd) - 1] = '\0';
|
||||||
} else if (!strcmp(p, "-m") && argc > 1) {
|
} else if (!strcmp(p, "-m") && argc > 1) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче