]> git.kaiwu.me - njs.git/commit
Fixed njs_value_index().
authorAlexander Borisov <alexander.borisov@nginx.com>
Tue, 17 Sep 2019 06:20:24 +0000 (09:20 +0300)
committerAlexander Borisov <alexander.borisov@nginx.com>
Tue, 17 Sep 2019 06:20:24 +0000 (09:20 +0300)
commit37853404214ed4603117d0390e556e3821eba17f
tree763116c03a963f86c11535719ae256c433f0f5f9
parentf331078b2cc8109111dd45bf155cd83bcd13695c
Fixed njs_value_index().

Previous, there were several issues with njs_values_hash_test().
1) The function assumed string types of left and right values are identical.
   (If current value is a long string it assumed the second value is also
   a long string). Long vs short strings collision.
2) The function assumed if hashes are identical value length are equal.
   Long vs long string collision.

The fix is to always check value sizes.

In addition, for short strings njs_value_index() calculated hash value including
padding bytes (which values are undefined). It could result in identical
short strings (but with different padding bytes) treated as different strings.
src/njs_string.c
src/test/njs_unit_test.c