Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed strcasestr() #3076

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ int janus_sdp_process_remote(void *ice_handle, janus_sdp *remote_sdp, gboolean r
if(a && a->name && a->value) {
if(!strcasecmp(a->name, "fingerprint")) {
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Fingerprint (global) : %s\n", handle->handle_id, a->value);
if(strcasestr(a->value, "sha-256 ") == a->value) {
if(!strncasecmp(a->value, "sha-256 ", strlen("sha-256 "))) {
rhashing = g_strdup("sha-256");
rfingerprint = g_strdup(a->value + strlen("sha-256 "));
} else if(strcasestr(a->value, "sha-1 ") == a->value) {
} else if(!strncasecmp(a->value, "sha-1 ", strlen("sha-1 "))) {
JANUS_LOG(LOG_WARN, "[%"SCNu64"] Hashing algorithm not the one we expected (sha-1 instead of sha-256), but that's ok\n", handle->handle_id);
rhashing = g_strdup("sha-1");
rfingerprint = g_strdup(a->value + strlen("sha-1 "));
Expand Down Expand Up @@ -342,12 +342,12 @@ int janus_sdp_process_remote(void *ice_handle, janus_sdp *remote_sdp, gboolean r
}
} else if(!strcasecmp(a->name, "fingerprint")) {
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Fingerprint (local) : %s\n", handle->handle_id, a->value);
if(strcasestr(a->value, "sha-256 ") == a->value) {
if(!strncasecmp(a->value, "sha-256 ", strlen("sha-256 "))) {
g_free(rhashing); /* FIXME We're overwriting the global one, if any */
rhashing = g_strdup("sha-256");
g_free(rfingerprint); /* FIXME We're overwriting the global one, if any */
rfingerprint = g_strdup(a->value + strlen("sha-256 "));
} else if(strcasestr(a->value, "sha-1 ") == a->value) {
} else if(!strncasecmp(a->value, "sha-1 ", strlen("sha-1 "))) {
JANUS_LOG(LOG_WARN, "[%"SCNu64"] Hashing algorithm not the one we expected (sha-1 instead of sha-256), but that's ok\n", handle->handle_id);
g_free(rhashing); /* FIXME We're overwriting the global one, if any */
rhashing = g_strdup("sha-1");
Expand All @@ -357,6 +357,7 @@ int janus_sdp_process_remote(void *ice_handle, janus_sdp *remote_sdp, gboolean r
/* FIXME We should handle this somehow anyway... OpenSSL supports them all */
JANUS_LOG(LOG_WARN, "[%"SCNu64"] Hashing algorithm not the one we expected (sha-256), *NOT* cool\n", handle->handle_id);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this empty line

} else if(!strcasecmp(a->name, "setup")) {
JANUS_LOG(LOG_VERB, "[%"SCNu64"] DTLS setup (local): %s\n", handle->handle_id, a->value);
if(!update) {
Expand Down