diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-08-08 19:44:19 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-08-11 01:19:27 +0200 |
commit | 5718e3487ba3b26aba341070be0b6b0b4de45ea3 (patch) | |
tree | 7039d67a396bcfc5f8e85ce7c2acca3032c7b7e5 /libavformat/rtmppkt.c | |
parent | 205a4502d3da9de2db75d2c965c9d065574e9266 (diff) | |
download | ffmpeg-5718e3487ba3b26aba341070be0b6b0b4de45ea3.tar.gz |
rtmp: Do not misuse memcmp
CC: libav-stable@libav.org
Diffstat (limited to 'libavformat/rtmppkt.c')
-rw-r--r-- | libavformat/rtmppkt.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 59bdd6dc06..8f3912272e 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); +} |