History

avformat/sdp: Check before appending ","

Found by reviewing code related to CID1500301 String not null terminated

Michael Niedermayer committed 2 years ago

Commit 5b828521 parent a3d3a581 file · +3 −0Browse files

Unified · Split

libavformat/sdp.c+3−0
@@ -203,6 +203,8 @@ static int extradata2psets(AVFormatContext *s, const AVCodecParameters *par, · 202 unmodified lines
203203 continue;
204204 }
205205 if (p != (psets + strlen(pset_string))) {
206+ if (p - psets >= MAX_PSET_SIZE)
207+ goto fail_in_loop;
206208 *p = ',';
207209 p++;
208210 }
@@ -213,6 +215,7 @@ static int extradata2psets(AVFormatContext *s, const AVCodecParameters *par, · 4 unmodified lines
213215 if (!av_base64_encode(p, MAX_PSET_SIZE - (p - psets), r, r1 - r)) {
214216 av_log(s, AV_LOG_ERROR, "Cannot Base64-encode %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"!\n",
215217 MAX_PSET_SIZE - (p - psets), r1 - r);
218+fail_in_loop:
216219 av_free(psets);
217220 av_free(tmpbuf);
218221

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t