aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtmppkt.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-08-08 19:44:19 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-08-24 16:21:24 +0200
commitdd923878e8efd85e27a0c6ea83175e166d273e28 (patch)
treead049a3b43f43969ab278806f592576badb3f67c /libavformat/rtmppkt.c
parente897e0631ae6ae74c74198aa5d5ff223d01ab8da (diff)
downloadffmpeg-dd923878e8efd85e27a0c6ea83175e166d273e28.tar.gz
rtmp: Do not misuse memcmp
CC: libav-stable@libav.org (cherry picked from commit 5718e3487ba3b26aba341070be0b6b0b4de45ea3) Signed-off-by: Luca Barbato <lu_zero@gentoo.org> Conflicts: libavformat/rtmpproto.c
Diffstat (limited to 'libavformat/rtmppkt.c')
-rw-r--r--libavformat/rtmppkt.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 3af56270d2..ace77297c6 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -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);
+}