-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
SrsRtcTcpConn::read_packet should use read_fully instead of read #3842
Comments
This is indeed an error. Can you submit a PR (Pull Request)?
|
I'm a bit busy now, can you just fix this? only a single line. |
I've made some changes, please review, @sandro-qiang. Could you explain how to test the client (can you provide a client demo that does not use the srs_error_t SrsRtcTcpConn::read_packet(char* pkt, int* nb_pkt)
{
srs_error_t err = srs_success;
// Read length in 2 bytes @doc: https://www.rfc-editor.org/rfc/rfc4571#section-2
ssize_t nread = 0; uint8_t b[2];
if((err = skt_->read((char*)b, sizeof(b), &nread)) != srs_success) {
return srs_error_wrap(err, "rtc tcp conn read len");
}
uint16_t npkt = uint16_t(b[0])<<8 | uint16_t(b[1]);
if (npkt > *nb_pkt) {
return srs_error_new(ERROR_RTC_TCP_SIZE, "invalid size=%u exceed %d", npkt, *nb_pkt);
}
// Read a RTC pkt such as STUN, DTLS or RTP/RTCP
if((err = skt_->read(pkt, npkt, &nread)) != srs_success) {
return srs_error_wrap(err, "rtc tcp conn read body");
}
*nb_pkt = npkt;
return err;
}
|
Please submit a PR (Pull Request) directly, and let's discuss it on the PR.
|
Full demo involve a lot of logic, |
Describe the bug
read_packet
useskt_->read
to read packet length, notskt_->read_fully
. for client not usingtcp_no_delay
option, this may lead to read wrong packet length.Version
5 and 6
The text was updated successfully, but these errors were encountered: