1
0
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:
Gene Oden
2022-03-03 15:24:56 -08:00
parent b5ce8fa96a
commit 196fe36971
2 changed files with 14 additions and 9 deletions

View File

@@ -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;