Welcome! Log In Create A New Profile

Advanced

Inconsistent len of complex value using zero flag

August 17, 2021 11:30AM
Hi all,

Something I bumped into today –

When using the zero flag of ngx_http_compile_complex_value_t (for example, using
ngx_http_set_complex_value_zero_slot) the length of the resulting string is inconsistent -

1. If the complex value is a simple string, the length does not include the null terminator.
2. If the complex value includes variables, the length includes the null terminator.

This happens because ngx_http_script_done adds code to copy the null explicitly, while simple strings
are copied as-is from val->value at the beginning of ngx_http_complex_value.

I assume that usually the length is not used when asking for a null terminated string.
However, in my case, I’m parsing the resulting value, and I’m supporting several different formats.
In some flows, I’m parsing the value using nginx functions (e.g. ngx_atoi) while in other flows,
I’m using a glibc function (strptime).

IMHO, the correct behavior is to change the impl so that it will never count the null terminator in the length.
Maybe add a ‘zero’ flag on ngx_http_complex_value_t, and do something like –
value->len = len – val->zero;

Thanks

Eran

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Inconsistent len of complex value using zero flag

erankor 506 August 17, 2021 11:30AM

Re: Inconsistent len of complex value using zero flag

Maxim Dounin 226 August 17, 2021 06:44PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 101
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready