mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-09-11 13:30:43 +03:00
knownhosts, config: Avoid using MT-unsafe implementations of strtok()
Use the POSIX strtok_r() or equivalent implementations to resolve. Thanks to @wez1 for the early review. Fixes #104 Signed-off-by: Gene Oden <goden@fb.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
This commit is contained in:
@@ -890,7 +890,7 @@ ssh_config_parse_line(ssh_session session,
|
||||
case SOC_PROTOCOL:
|
||||
p = ssh_config_get_str_tok(&s, NULL);
|
||||
if (p && *parsing) {
|
||||
char *a, *b;
|
||||
char *a, *b, *save = NULL;
|
||||
b = strdup(p);
|
||||
if (b == NULL) {
|
||||
SAFE_FREE(x);
|
||||
@@ -900,7 +900,7 @@ ssh_config_parse_line(ssh_session session,
|
||||
i = 0;
|
||||
ssh_options_set(session, SSH_OPTIONS_SSH2, &i);
|
||||
|
||||
for (a = strtok(b, ","); a; a = strtok(NULL, ",")) {
|
||||
for (a = strtok_r(b, ",", &save); a; a = strtok_r(NULL, ",", &save)) {
|
||||
switch (atoi(a)) {
|
||||
case 1:
|
||||
break;
|
||||
|
Reference in New Issue
Block a user