Page 1 of 1

vlc filter plugin integer parameter overflow

Posted: 11 May 2020 15:43
by aleksas
I'm trying to pass a 64 bit pointer to a data structure via plugin int parameter. From the plugin headers it looks that it deals with int64_t wich suggests that 64 bit pointer should not be a problem.
But when i'm passing a pointer value, what i get inside filter plugin is int32 max value (2,147,483,647).

Same experiment with 32 bit acts as expected. Pointer stays within 32 bit, value received in plugin is a valid pointer.

Is there some 32 bit limitation built in the plugin for int param?

p.s. the code resolving the parameter value

Code: Select all

struct filter_sys_t { atomic_llong i_shareddata }; atomic_init(&p_sys->i_shareddata, var_CreateGetIntegerCommand(p_filter, CFG_PREFIX "shareddata"));

Re: vlc filter plugin integer parameter overflow

Posted: 13 May 2020 15:43
by aleksas
UPDATE

Tried to use `_Atomic_address` together with `var_CreateGetAddress` function instead of `atomic_int` but the result is the same.

OS: Windows 10
VLC: 3.0.10

[url=https://stackoverflow.com/questions/61747918/vlc-filter-plugin-integer-parameter-overflow]Reposted[/url]

Re: vlc filter plugin integer parameter overflow

Posted: 13 May 2020 17:30
by Rémi Denis-Courmont
The range is INT64_MIN to INT64_MAX.

Re: vlc filter plugin integer parameter overflow

Posted: 14 May 2020 14:52
by aleksas
The range is INT64_MIN to INT64_MAX.
That is what I would expect, but.. Repeated experiment shows different result:

On code controlling libvlc side:

Code: Select all

int64_t testvalue = 0x00000000FFFFFFFF; sprintf(sandbox_options, "sandboxfilter{testvalue=%lld}", testvalue);
gives: "sandboxfilter{testvalue=4294967295}"


which is passed as part of vlc_argv

on the filter side in Create function value is recovered using following code:

Code: Select all

struct filter_sys_t { atomic_int i_testvalue; }; (...) atomic_init(&p_sys->i_testvalue, var_CreateGetIntegerCommand(p_filter, CFG_PREFIX "testvalue"));
expected p_sys->i_testvalue value after this function is 4294967295 but it actually is 2147483647 (INT32_MAX)

setting testvalue to anything above 0x000000007FFFFFFF (INT32_MAX)

on filter side is set back to INT32_MAX .

Re: vlc filter plugin integer parameter overflow

Posted: 14 May 2020 17:31
by Rémi Denis-Courmont
With configuration chain, the range is LONG_MIN to LONG_MAX.

Re: vlc filter plugin integer parameter overflow

Posted: 15 May 2020 13:49
by aleksas
The work around I use is to combine two long values into 64bit void *. Is there a better solution?