Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
5718e348
Commit
5718e348
authored
Aug 08, 2013
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtmp: Do not misuse memcmp
CC: libav-stable@libav.org
parent
205a4502
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
12 deletions
+53
-12
rtmppkt.c
libavformat/rtmppkt.c
+33
-0
rtmppkt.h
libavformat/rtmppkt.h
+7
-0
rtmpproto.c
libavformat/rtmpproto.c
+13
-12
No files found.
libavformat/rtmppkt.c
View file @
5718e348
...
...
@@ -525,3 +525,36 @@ void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p)
av_log
(
ctx
,
AV_LOG_DEBUG
,
"
\n
"
);
}
}
int
ff_amf_match_string
(
const
uint8_t
*
data
,
int
size
,
const
char
*
str
)
{
int
len
=
strlen
(
str
);
int
amf_len
,
type
;
if
(
size
<
1
)
return
0
;
type
=
*
data
++
;
if
(
type
!=
AMF_DATA_TYPE_LONG_STRING
&&
type
!=
AMF_DATA_TYPE_STRING
)
return
0
;
if
(
type
==
AMF_DATA_TYPE_LONG_STRING
)
{
if
((
size
-=
4
+
1
)
<
0
)
return
0
;
amf_len
=
bytestream_get_be32
(
&
data
);
}
else
{
if
((
size
-=
2
+
1
)
<
0
)
return
0
;
amf_len
=
bytestream_get_be16
(
&
data
);
}
if
(
amf_len
>
size
)
return
0
;
if
(
amf_len
!=
len
)
return
0
;
return
!
memcmp
(
data
,
str
,
len
);
}
libavformat/rtmppkt.h
View file @
5718e348
...
...
@@ -282,6 +282,13 @@ int ff_amf_read_string(GetByteContext *gbc, uint8_t *str,
*/
int
ff_amf_read_null
(
GetByteContext
*
gbc
);
/**
* Match AMF string with a NULL-terminated string.
*
* @return 0 if the strings do not match.
*/
int
ff_amf_match_string
(
const
uint8_t
*
data
,
int
size
,
const
char
*
str
);
/** @} */
// AMF funcs
...
...
libavformat/rtmpproto.c
View file @
5718e348
...
...
@@ -1909,7 +1909,7 @@ static int handle_invoke_result(URLContext *s, RTMPPacket *pkt)
return
ret
;
}
if
(
!
memcmp
(
tracked_method
,
"connect"
,
7
))
{
if
(
!
strcmp
(
tracked_method
,
"connect"
))
{
if
(
!
rt
->
is_input
)
{
if
((
ret
=
gen_release_stream
(
s
,
rt
))
<
0
)
goto
fail
;
...
...
@@ -1935,7 +1935,7 @@ static int handle_invoke_result(URLContext *s, RTMPPacket *pkt)
goto
fail
;
}
}
}
else
if
(
!
memcmp
(
tracked_method
,
"createStream"
,
12
))
{
}
else
if
(
!
strcmp
(
tracked_method
,
"createStream"
))
{
//extract a number from the result
if
(
pkt
->
data
[
10
]
||
pkt
->
data
[
19
]
!=
5
||
pkt
->
data
[
20
])
{
av_log
(
s
,
AV_LOG_WARNING
,
"Unexpected reply on connect()
\n
"
);
...
...
@@ -1998,23 +1998,23 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt)
int
ret
=
0
;
//TODO: check for the messages sent for wrong state?
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\006
_error"
,
9
))
{
if
(
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"_error"
))
{
if
((
ret
=
handle_invoke_error
(
s
,
pkt
))
<
0
)
return
ret
;
}
else
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\007
_result"
,
10
))
{
}
else
if
(
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"_result"
))
{
if
((
ret
=
handle_invoke_result
(
s
,
pkt
))
<
0
)
return
ret
;
}
else
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\010
onStatus"
,
11
))
{
}
else
if
(
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"onStatus"
))
{
if
((
ret
=
handle_invoke_status
(
s
,
pkt
))
<
0
)
return
ret
;
}
else
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\010
onBWDone"
,
11
))
{
}
else
if
(
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"onBWDone"
))
{
if
((
ret
=
gen_check_bw
(
s
,
rt
))
<
0
)
return
ret
;
}
else
if
(
!
memcmp
(
pkt
->
data
,
"
\002\000\015
releaseStream"
,
16
)
||
!
memcmp
(
pkt
->
data
,
"
\002\000\011
FCPublish"
,
12
)
||
!
memcmp
(
pkt
->
data
,
"
\002\000\007
publish"
,
10
)
||
!
memcmp
(
pkt
->
data
,
"
\002\000\010
_checkbw"
,
11
)
||
!
memcmp
(
pkt
->
data
,
"
\002\000\014
createStream"
,
15
))
{
}
else
if
(
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"releaseStream"
)
||
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"FCPublish"
)
||
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"publish"
)
||
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"_checkbw"
)
||
ff_amf_match_string
(
pkt
->
data
,
pkt
->
size
,
"createStream"
))
{
if
((
ret
=
send_invoke_response
(
s
,
pkt
))
<
0
)
return
ret
;
}
...
...
@@ -2210,7 +2210,8 @@ static int get_packet(URLContext *s, int for_header)
continue
;
}
if
(
rpkt
.
type
==
RTMP_PT_VIDEO
||
rpkt
.
type
==
RTMP_PT_AUDIO
||
(
rpkt
.
type
==
RTMP_PT_NOTIFY
&&
!
memcmp
(
"
\002\000\012
onMetaData"
,
rpkt
.
data
,
13
)))
{
(
rpkt
.
type
==
RTMP_PT_NOTIFY
&&
ff_amf_match_string
(
rpkt
.
data
,
rpkt
.
size
,
"onMetaData"
)))
{
ts
=
rpkt
.
timestamp
;
// generate packet header and put data into buffer for FLV demuxer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment