mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Revert "Remove deprecated ByteBufferReader and ByteBufferWriter functions"
This reverts commit e0e03ba73a
.
Reason for revert: Speculative rollback (breaks WebKit Linux Leak)
Original change's description:
> Remove deprecated ByteBufferReader and ByteBufferWriter functions
>
> This completes the conversion of ByteBufferReader and ByteBufferWriter
> to uint8_t.
>
> No-Try: True
> Bug: webrtc:15661
> Change-Id: I4152a8a4fd2462282d4107b3c2eed19acc8b29b0
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/331640
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#41403}
Bug: webrtc:15661, chromium:1513059
Change-Id: I3938b8209f5cc1596307deadac157a8f6c2b2253
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/331940
Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41411}
This commit is contained in:
parent
c5daa63cef
commit
ca58f0eb9d
5 changed files with 23 additions and 8 deletions
|
@ -587,7 +587,7 @@ bool StunMessage::AddFingerprint() {
|
|||
|
||||
bool StunMessage::Read(ByteBufferReader* buf) {
|
||||
// Keep a copy of the buffer data around for later verification.
|
||||
buffer_.assign(reinterpret_cast<const char*>(buf->Data()), buf->Length());
|
||||
buffer_.assign(buf->Data(), buf->Length());
|
||||
|
||||
if (!buf->ReadUInt16(&type_)) {
|
||||
return false;
|
||||
|
|
|
@ -1213,7 +1213,7 @@ void PseudoTcp::parseOptions(const char* data, uint32_t len) {
|
|||
|
||||
// Content of this option.
|
||||
if (opt_len <= buf.Length()) {
|
||||
applyOption(kind, reinterpret_cast<const char*>(buf.Data()), opt_len);
|
||||
applyOption(kind, buf.Data(), opt_len);
|
||||
buf.Consume(opt_len);
|
||||
} else {
|
||||
RTC_LOG(LS_ERROR) << "Invalid option length received.";
|
||||
|
|
|
@ -139,6 +139,10 @@ bool ByteBufferReader::ReadBytes(rtc::ArrayView<uint8_t> val) {
|
|||
return ReadBytes(val.data(), val.size());
|
||||
}
|
||||
|
||||
bool ByteBufferReader::ReadBytes(char* val, size_t len) {
|
||||
return ReadBytes(reinterpret_cast<uint8_t*>(val), len);
|
||||
}
|
||||
|
||||
// Private function supporting the other Read* functions.
|
||||
bool ByteBufferReader::ReadBytes(uint8_t* val, size_t len) {
|
||||
if (len > Length()) {
|
||||
|
|
|
@ -100,6 +100,12 @@ class ByteBufferWriterT {
|
|||
void WriteBytes(const uint8_t* val, size_t len) {
|
||||
WriteBytesInternal(reinterpret_cast<const value_type*>(val), len);
|
||||
}
|
||||
// For backwards compatibility: Write an array of char
|
||||
// TODO(bugs.webrtc.org/15665): Remove when users converted
|
||||
[[deprecated("Use WriteString")]] void WriteBytes(const char* val,
|
||||
size_t len) {
|
||||
WriteBytesInternal(reinterpret_cast<const value_type*>(val), len);
|
||||
}
|
||||
|
||||
// Reserves the given number of bytes and returns a value_type* that can be
|
||||
// written into. Useful for functions that require a value_type* buffer and
|
||||
|
@ -157,10 +163,14 @@ class ByteBufferReader {
|
|||
ByteBufferReader(const ByteBufferReader&) = delete;
|
||||
ByteBufferReader& operator=(const ByteBufferReader&) = delete;
|
||||
|
||||
const uint8_t* Data() const { return bytes_ + start_; }
|
||||
// Returns start of unprocessed data.
|
||||
// TODO(bugs.webrtc.org/15661): Deprecate and remove.
|
||||
const char* Data() const {
|
||||
return reinterpret_cast<const char*>(bytes_ + start_);
|
||||
}
|
||||
// Returns number of unprocessed bytes.
|
||||
size_t Length() const { return end_ - start_; }
|
||||
// Returns a view of the unprocessed data. Does not move current position.
|
||||
// Returns a view of the unprocessed data.
|
||||
rtc::ArrayView<const uint8_t> DataView() const {
|
||||
return rtc::ArrayView<const uint8_t>(bytes_ + start_, end_ - start_);
|
||||
}
|
||||
|
@ -173,8 +183,11 @@ class ByteBufferReader {
|
|||
bool ReadUInt32(uint32_t* val);
|
||||
bool ReadUInt64(uint64_t* val);
|
||||
bool ReadUVarint(uint64_t* val);
|
||||
// Copies the val.size() next bytes into val.data().
|
||||
bool ReadBytes(rtc::ArrayView<uint8_t> val);
|
||||
// For backwards compatibility.
|
||||
// TODO(bugs.webrtc.org/15661): Deprecate and remove.
|
||||
[[deprecated("Read using ArrayView")]] bool ReadBytes(char* val, size_t len);
|
||||
|
||||
// Appends next `len` bytes from the buffer to `val`. Returns false
|
||||
// if there is less than `len` bytes left.
|
||||
bool ReadString(std::string* val, size_t len);
|
||||
|
|
|
@ -75,9 +75,7 @@ void AsyncSocksProxyServerSocket::ProcessInput(char* data, size_t* len) {
|
|||
|
||||
// Consume parsed data
|
||||
*len = response.Length();
|
||||
if (response.Length() > 0) {
|
||||
memmove(data, response.DataView().data(), *len);
|
||||
}
|
||||
memmove(data, response.Data(), *len);
|
||||
}
|
||||
|
||||
void AsyncSocksProxyServerSocket::DirectSend(const ByteBufferWriter& buf) {
|
||||
|
|
Loading…
Reference in a new issue