[fix] fix SDP parsing offset bug in GetIceUsername

This commit is contained in:
dijunkun committed 2026-02-24 11:10:40 +08:00
1 parent cdbdee378e
commit a441aec3ef
1 file changed
+7 -4
+7 -4
View File
@@ -5,7 +5,7 @@
int CommonDummy();
constexpr size_t HASH_STRING_PIECE(const char *string_piece) {
constexpr size_t HASH_STRING_PIECE(const char* string_piece) {
std::size_t result = 0;
while (*string_piece) {
result = (result * 131) + *string_piece++;
@@ -13,17 +13,20 @@ constexpr size_t HASH_STRING_PIECE(const char *string_piece) {
return result;
}
constexpr size_t operator"" _H(const char *string_piece, size_t) {
constexpr size_t operator"" _H(const char* string_piece, size_t) {
return HASH_STRING_PIECE(string_piece);
}
inline const std::string GetIceUsername(const std::string &sdp) {
inline const std::string GetIceUsername(const std::string& sdp) {
std::string result = "";
std::string start = "ice-ufrag:";
std::string end = "\r\n";
size_t startPos = sdp.find(start);
size_t endPos = sdp.find(end);
size_t endPos = std::string::npos;
if (startPos != std::string::npos) {
endPos = sdp.find(end, startPos + start.length());
}
if (startPos != std::string::npos && endPos != std::string::npos) {
result = sdp.substr(startPos + start.length(),