]> granicus.if.org Git - rtmpdump/commitdiff
Fix AMF_EncodeString to handle Long Strings
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Thu, 4 Mar 2010 07:52:02 +0000 (07:52 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Thu, 4 Mar 2010 07:52:02 +0000 (07:52 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@285 400ebc74-4327-4243-bc38-086b20814532

amf.c

diff --git a/amf.c b/amf.c
index 9f322c3907b1040067d734ddb6c89154e6827ce9..6c07a717282b9cec33e8400b9fd60cdb07bfeee3 100644 (file)
--- 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;