From: hyc Date: Thu, 4 Mar 2010 07:52:02 +0000 (+0000) Subject: Fix AMF_EncodeString to handle Long Strings X-Git-Tag: v2.4~244 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea84cbfbaa4bca4a4126b689eb7b86cbf311e09f;p=rtmpdump Fix AMF_EncodeString to handle Long Strings git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@285 400ebc74-4327-4243-bc38-086b20814532 --- diff --git a/amf.c b/amf.c index 9f322c3..6c07a71 100644 --- a/amf.c +++ b/amf.c @@ -169,13 +169,22 @@ AMF_EncodeInt32(char *output, char *outend, int nVal) char * AMF_EncodeString(char *output, char *outend, const AVal * bv) { - if (output + 1 + 2 + bv->av_len > outend) + if ((bv->av_len < 65536 && output + 1 + 2 + bv->av_len > outend) || + output + 1 + 4 + bv->av_len > outend) return NULL; - *output++ = AMF_STRING; + if (bv->av_len < 65536) + { + *output++ = AMF_STRING; - output = AMF_EncodeInt16(output, outend, bv->av_len); + output = AMF_EncodeInt16(output, outend, bv->av_len); + } + else + { + *output++ = AMF_LONG_STRING; + output = AMF_EncodeInt32(output, outend, bv->av_len); + } memcpy(output, bv->av_val, bv->av_len); output += bv->av_len;