Skip to content

Commit

Permalink
Limit the ice ufrag and pwd.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 15, 2023
1 parent 382bc84 commit 5481fc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion trunk/src/app/srs_app_rtc_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,16 @@ srs_error_t SrsGoApiRtcWhip::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
ruc->req_->vhost = ruc->req_->host;
ruc->req_->app = app.empty() ? "live" : app;
ruc->req_->stream = stream.empty() ? "livestream" : stream;
ruc->req_->param = r->query();

ruc->req_->ice_ufrag_ = r->query_get("ice-ufrag");
ruc->req_->ice_pwd_ = r->query_get("ice-pwd");
ruc->req_->param = r->query();
if (!ruc->req_->ice_ufrag_.empty() && (ruc->req_->ice_ufrag_.length() < 4 || ruc->req_->ice_ufrag_.length() > 32)) {
return srs_error_new(ERROR_RTC_INVALID_ICE, "Invalid ice-ufrag %s", ruc->req_->ice_ufrag_.c_str());
}
if (!ruc->req_->ice_pwd_.empty() && (ruc->req_->ice_pwd_.length() < 22 || ruc->req_->ice_pwd_.length() > 32)) {
return srs_error_new(ERROR_RTC_INVALID_ICE, "Invalid ice-pwd %s", ruc->req_->ice_pwd_.c_str());
}

// discovery vhost, resolve the vhost from config
SrsConfDirective* parsed_vhost = _srs_config->get_vhost(ruc->req_->vhost);
Expand Down
3 changes: 2 additions & 1 deletion trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@
XX(ERROR_RTC_TCP_PACKET , 5033, "RtcTcpStun", "RTC TCP first packet must be STUN") \
XX(ERROR_RTC_TCP_STUN , 5034, "RtcTcpSession", "RTC TCP packet is invalid for session not found") \
XX(ERROR_RTC_TCP_UNIQUE , 5035, "RtcUnique", "RTC only support one UDP or TCP network") \
XX(ERROR_RTC_INVALID_SESSION , 5036, "RtcInvalidSession", "Invalid request for no RTC session matched")
XX(ERROR_RTC_INVALID_SESSION , 5036, "RtcInvalidSession", "Invalid request for no RTC session matched") \
XX(ERROR_RTC_INVALID_ICE , 5037, "RtcInvalidIce", "Invalid ICE ufrag or pwd")

/**************************************************/
/* SRT protocol error. */
Expand Down

0 comments on commit 5481fc1

Please sign in to comment.