Undefined behavior sanitizer (ubsan) => Null pointer passed as argument 2, which is declared to never be null.
- Dominant language
- C++
- Stars
- 897
- Forks
- 177
- PR merge metrics
- No merged PRs in 30d
Description
It is about calling memcpy(...) with null for src argument from WriteBytes(...) which is called from AppendStreamFrame(...) - In Process of packet serialization. It seems this is completely valid for stream frame - To have zero data. It is not good to call memcpy where this causes undefined behavior according to [C++ standard](https://en.cppreference.com/w/c/string/byte/memcpy):
>The behavior is undefined if either dest or src is an invalid or null pointer.
In my memcpy implementation see __nonnull attribute:
>extern void *memcpy (void *_restrict __dest, const void *_restrict __src, size_t __n) __THROW __nonnull ((1, 2));
The problematic code is here calling WriteBytes(...) which leads to calling memcpy(...) with nullptr for src argument:
```
bool QuicFramer::AppendStreamFrame(const QuicStreamFrame& frame,
bool no_stream_frame_length,
QuicDataWriter* writer) {
...
...
if (!writer->WriteBytes(frame.data_buffer, frame.data_length)) {
QUIC_BUG(quic_bug_10850_84) << "Writing frame data failed.";
return false;
}
return true;
...
...
}
```
Contributor guide
Assessment
This issue has not been assessed yet.