Problem using %V in snprintf
Eran Kornblau
eran.kornblau at kaltura.com
Tue Jun 5 19:46:19 UTC 2018
> -----Original Message-----
> From: nginx-devel [mailto:nginx-devel-bounces at nginx.org] On Behalf Of Raphael Mazelier
> Sent: Tuesday, June 5, 2018 10:42 PM
> To: nginx-devel at nginx.org
> Subject: Problem using %V in snprintf
>
> Hello Ngx devs,
>
> I'm unsure if it the good ml for posting some question about coding nginx module. Anyway here it is.
>
> So I'm hacking a bit the nginx-rtmp-module (you could see my fork here :
> https://github.com/ut0mt8/nginx-rtmp-module/tree/cenc/dash/ )
>
> A detail puzzle me.
>
> "wdv_data" is config directive filled with base64 text:
>
> { ngx_string("dash_wdv_data"),
> NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|NGX_CONF_TAKE1,
> ngx_conf_set_str_slot,
> NGX_RTMP_APP_CONF_OFFSET,
> offsetof(ngx_rtmp_dash_app_conf_t, wdv_data),
> NULL },
>
> When I'm trying to use as it, and to write it using :
>
> p = buffer;
> p = ngx_slprintf(p, last, "- %V -", dacf->wdv_data); n = ngx_write_fd(fd, buffer, p - buffer);
>
You are missing a '&', %V expects ngx_str_t* while you passed ngx_str_t
Eran
> I got a segfault in ngx_vslprintf.
> #0 0x0000000000418430 in ngx_vslprintf (buf=0xd3cf2c <buffer.26926+588> " <Period start=\"PT0S\" id=\"dash\">\n", last=0xe3cce0 <buffer_depth.26929> "P0Y00M00DT0H00M04.000S",
> fmt=0x4e12f9 "V -", args=args at entry=0x7ffc07eef6f8) at
> src/core/ngx_string.c:237
> 237 len = ngx_min(((size_t) (last - buf)), v->len);
>
> It seems that v->len is not filled ?!
> (gdb) print v->len
> Cannot access memory at address 0x90
>
> Using the form :
>
> p = ngx_slprintf(p, last, "- %S -", dacf->wdv_data.data);
>
> work well.
>
> Is %V not supposed to be used with ngx_str_t ?
>
> Best,
>
> --
> Raphael Mazelier
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
More information about the nginx-devel
mailing list