mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-09 22:11:08 +02:00
Merge remote branch 'origin/safe-amf-parser' into video-on-demand
This commit is contained in:
commit
28e5b05e01
|
@ -61,9 +61,10 @@ ngx_rtmp_amf_debug(const char* op, ngx_log_t *log, u_char *p, size_t n)
|
|||
static ngx_int_t
|
||||
ngx_rtmp_amf_get(ngx_rtmp_amf_ctx_t *ctx, void *p, size_t n)
|
||||
{
|
||||
ngx_buf_t *b;
|
||||
size_t size;
|
||||
ngx_chain_t *l;
|
||||
size_t offset;
|
||||
u_char *pos, *last;
|
||||
#ifdef NGX_DEBUG
|
||||
void *op = p;
|
||||
size_t on = n;
|
||||
|
@ -72,16 +73,16 @@ ngx_rtmp_amf_get(ngx_rtmp_amf_ctx_t *ctx, void *p, size_t n)
|
|||
if (!n)
|
||||
return NGX_OK;
|
||||
|
||||
for(l = ctx->link; l; l = l->next) {
|
||||
for(l = ctx->link, offset = ctx->offset; l; l = l->next, offset = 0) {
|
||||
|
||||
b = l->buf;
|
||||
pos = l->buf->pos + offset;
|
||||
last = l->buf->last;
|
||||
|
||||
if (b->last >= n + b->pos) {
|
||||
if (last >= pos + n) {
|
||||
if (p) {
|
||||
p = ngx_cpymem(p, b->pos, n);
|
||||
p = ngx_cpymem(p, pos, n);
|
||||
}
|
||||
b->pos += n;
|
||||
|
||||
ctx->offset = offset + n;
|
||||
ctx->link = l;
|
||||
|
||||
#ifdef NGX_DEBUG
|
||||
|
@ -91,10 +92,10 @@ ngx_rtmp_amf_get(ngx_rtmp_amf_ctx_t *ctx, void *p, size_t n)
|
|||
return NGX_OK;
|
||||
}
|
||||
|
||||
size = b->last - b->pos;
|
||||
size = last - pos;
|
||||
|
||||
if (p) {
|
||||
p = ngx_cpymem(p, b->pos, size);
|
||||
p = ngx_cpymem(p, pos, size);
|
||||
}
|
||||
|
||||
n -= size;
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef ngx_chain_t * (*ngx_rtmp_amf_alloc_pt)(void *arg);
|
|||
|
||||
typedef struct {
|
||||
ngx_chain_t *link, *first;
|
||||
size_t offset;
|
||||
ngx_rtmp_amf_alloc_pt alloc;
|
||||
void *arg;
|
||||
ngx_log_t *log;
|
||||
|
|
|
@ -206,6 +206,7 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,
|
|||
cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);
|
||||
|
||||
/* read AMF func name & transaction id */
|
||||
ngx_memzero(&act, sizeof(act));
|
||||
act.link = in;
|
||||
act.log = s->connection->log;
|
||||
memset(func, 0, sizeof(func));
|
||||
|
@ -218,6 +219,10 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,
|
|||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
/* skip name */
|
||||
in = act.link;
|
||||
in->buf->pos += act.offset;
|
||||
|
||||
len = ngx_strlen(func);
|
||||
|
||||
ch = ngx_hash_find(&cmcf->amf_hash,
|
||||
|
@ -251,6 +256,7 @@ ngx_rtmp_receive_amf(ngx_rtmp_session_t *s, ngx_chain_t *in,
|
|||
{
|
||||
ngx_rtmp_amf_ctx_t act;
|
||||
|
||||
ngx_memzero(&act, sizeof(act));
|
||||
act.link = in;
|
||||
act.log = s->connection->log;
|
||||
|
||||
|
|
Loading…
Reference in a new issue