diff options
| author | Anton <anton@picapica.im> | 2026-11-11 07:24:45 +0400 |
|---|---|---|
| committer | Anton <anton@picapica.im> | 2026-11-11 07:24:45 +0400 |
| commit | 15720f9ab20d41d7ba316e8e174f2bc1d2b611dc (patch) | |
| tree | a5dabc1bd4b5f5ab3cdcd1e52d8d7376dc19cd1a /pica-client/videodevice.cpp | |
| parent | d3b160a31eee3abfc5cb1e007ab6d7b2a54d8bce (diff) | |
| download | pica-pica-15720f9ab20d41d7ba316e8e174f2bc1d2b611dc.tar.gz pica-pica-15720f9ab20d41d7ba316e8e174f2bc1d2b611dc.zip | |
pica-client: impose limits on partial frames
Diffstat (limited to 'pica-client/videodevice.cpp')
| -rw-r--r-- | pica-client/videodevice.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pica-client/videodevice.cpp b/pica-client/videodevice.cpp index 67094aa..ac9a861 100644 --- a/pica-client/videodevice.cpp +++ b/pica-client/videodevice.cpp @@ -615,6 +615,11 @@ QList<VideoCaptureFormat> VideoDevice::CaptureFormats(const QString &device) return result; } +// A reassembled frame never legitimately approaches this; a stream that does +// is a peer flooding fragments that never carry the last-fragment flag, so the +// partial frame is dropped and reassembly resynchronizes at the next boundary. +static const int kMaxAssembledFrameBytes = 4 * 1024 * 1024; + VideoFrameAssembler::VideoFrameAssembler() : m_timestamp(0), m_lastSeq(0) { @@ -694,6 +699,19 @@ QByteArray VideoFrameAssembler::addFragment(quint16 seq_num, quint32 timestamp, m_buffer.clear(); m_buffer.append(data); + + /* Bound the partial frame: a peer that never sets the last-fragment flag + * would otherwise grow this without limit. Drop it and resync at the next + * frame boundary, exactly as for a lost fragment above. + */ + if (m_buffer.size() > kMaxAssembledFrameBytes) + { + m_buffer.clear(); + m_inProgress = false; + m_lastWasFrameEnd = false; + return QByteArray(); + } + m_timestamp = timestamp; m_inProgress = true; m_lastWasFrameEnd = isLast; |
