Commit 175d4991 authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

Fixing a substring match error in SDP Fingerprint comparison code

The issue is that different line ending encodings were not properly
handled (\r\n vs \n) in the fingerprint comparison code.  Due to this,
a connection between different platforms, such as Windows to Linux,
would fail the FingerprintMatch verification check and close the
connection.

Note: There may be a better way to normalize the line endings upstream
but I am not familiar enough with WebRTC to make that change.

Change-Id: I03fee025c81bf3c1b5f54204beed5c8d938cbbc8
Reviewed-on: https://chromium-review.googlesource.com/986657
Commit-Queue: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546962}
parent c6aed4c0
......@@ -417,18 +417,24 @@ bool FingerprintMismatch(String old_sdp, String new_sdp) {
// or createAnswer, so this only applies when there are no fingerprints.
// This is allowed.
const size_t new_fingerprint_pos = new_sdp.Find("\na=fingerprint:");
if (new_fingerprint_pos == kNotFound)
if (new_fingerprint_pos == kNotFound) {
return false;
}
// Look for fingerprint having been added. Not allowed.
const size_t old_fingerprint_pos = old_sdp.Find("\na=fingerprint:");
if (old_fingerprint_pos == kNotFound) {
return true;
}
// Look for fingerprint being modified. Not allowed.
const size_t old_fingerprint_end =
old_sdp.Find("\n", old_fingerprint_pos + 1);
const size_t new_fingerprint_end =
new_sdp.Find("\n", new_fingerprint_pos + 1);
// Look for fingerprint being modified. Not allowed. Handle differences in
// line endings ('\r\n' vs, '\n' when looking for the end of the fingerprint).
size_t old_fingerprint_end = old_sdp.Find("\r\n", old_fingerprint_pos + 1);
if (old_fingerprint_end == std::string::npos) {
old_fingerprint_end = old_sdp.Find("\n", old_fingerprint_pos + 1);
}
size_t new_fingerprint_end = new_sdp.Find("\r\n", new_fingerprint_pos + 1);
if (new_fingerprint_end == std::string::npos) {
new_fingerprint_end = new_sdp.Find("\n", new_fingerprint_pos + 1);
}
return old_sdp.Substring(old_fingerprint_pos,
old_fingerprint_end - old_fingerprint_pos) !=
new_sdp.Substring(new_fingerprint_pos,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment