From: hyc Date: Sat, 2 Jan 2010 23:10:00 +0000 (+0000) Subject: Fix: handle auth parameters in connect request X-Git-Tag: v2.4~337 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1960da5c0297a3fb8fa219db87503044981e104;p=rtmpdump Fix: handle auth parameters in connect request git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@170 400ebc74-4327-4243-bc38-086b20814532 --- diff --git a/rtmp.c b/rtmp.c index f13bb9f..be6bcd3 100644 --- a/rtmp.c +++ b/rtmp.c @@ -944,11 +944,9 @@ SendConnectPacket(RTMP * r) // add auth string if (r->Link.auth.av_len) { - if (enc+2 >= pend) + enc = AMF_EncodeBoolean(enc, pend, r->Link.authflag); + if (!enc) return false; - *enc++ = 0x01; - *enc++ = 0x01; - enc = AMF_EncodeString(enc, pend, &r->Link.auth); if (!enc) return false; diff --git a/rtmp.h b/rtmp.h index 6cf4bd0..590a59e 100644 --- a/rtmp.h +++ b/rtmp.h @@ -125,6 +125,7 @@ typedef struct RTMP_LNK AVal flashVer; AVal subscribepath; AVal token; + bool authflag; double seekTime; uint32_t length; diff --git a/rtmpsuck.c b/rtmpsuck.c index 7aad6f0..403ac59 100644 --- a/rtmpsuck.c +++ b/rtmpsuck.c @@ -189,8 +189,12 @@ ServeInvoke(STREAMING_SERVER *server, RTMPPacket *pack, const char *body) { pval = cobj.o_props[i].p_vu.p_aval; if (pval.av_val) - pval.av_val = strdup(pval.av_val); - LogPrintf("%.*s: %.*s\n", pname.av_len, pname.av_val, pval.av_len, pval.av_val); + { + pval.av_val = malloc(pval.av_len+1); + memcpy(pval.av_val, cobj.o_props[i].p_vu.p_aval.av_val, pval.av_len); + pval.av_val[pval.av_len] = '\0'; + } + LogPrintf("%.*s: %s\n", pname.av_len, pname.av_val, pval.av_val); } if (AVMATCH(&pname, &av_app)) { @@ -275,6 +279,19 @@ ServeInvoke(STREAMING_SERVER *server, RTMPPacket *pack, const char *body) if (pval.av_val) free(pval.av_val); } + if (obj.o_num > 3) + { + server->rc.Link.authflag = AMFProp_GetBoolean(&obj.o_props[3]); + if (obj.o_num > 4) + { + AVal tmp; + AMFProp_GetString(&obj.o_props[4], &tmp); + server->rc.Link.auth.av_len = tmp.av_len; + server->rc.Link.auth.av_val = malloc(tmp.av_len+1); + memcpy(server->rc.Link.auth.av_val, tmp.av_val, tmp.av_len); + server->rc.Link.auth.av_val[tmp.av_len] = '\0'; + } + } if (!RTMP_Connect(&server->rc)) {