bryancall opened a new pull request, #14076:
URL: https://github.com/apache/trafficserver/pull/14076

   Backport of [#13935](https://github.com/apache/trafficserver/pull/13935) to 
9.2.x.
   
   `ats_ip_pton()` takes a `std::string_view` but parsed the port with 
`atoi()`, which reads until it finds a non-digit. When the port digits were the 
last bytes of the input, it read past the end of the view, so a view of 
`1.2.3.4:80` taken from `1.2.3.4:8099` returned port 8099. The port is now 
parsed over the view only, in base 10 so a leading zero is not octal. Every 
in-bounds input gets the same port as before.
   
   Differences from the master change:
   
   - 9.2.x has no libswoc, so the port goes through `ts::svtoi()` from 
`tscpp/util/TextView.h` instead of `swoc::svtoi()`. Same arguments, same result 
for every port a real configuration uses.
   - `ts::svtoi()` saturates only once a value overflows 64 unsigned bits, so 
the saturation case in the new test uses 2^64 where master uses 2^63. Ports 
from 2^63 up to 2^64 now come out as the low 16 bits of the parsed value (for 
example 0 for 9223372036854775808 and 1 for 9223372036854775809), where 
`atoi()` gave 65535. Every value below 2^63 gives the same port as before. All 
of these are nonsense ports, and nothing in the tree depends on them.
   - The test file keeps 9.2.x's `<catch.hpp>` include.
   
   Test plan:
   
   - New `ats_ip_pton port` test case in 
`src/tscore/unit_tests/test_ink_inet.cc`: end-of-buffer ports, ports followed 
by more digits outside the view, empty, non-numeric, negative, octal-looking, 
out-of-range and saturating ports.
   - Built in the CI `rockylinux:8` image with the 9.2.x coverage job's 
configure flags (gcc-toolset-11, `--enable-werror --enable-debug`).
   - Without the `ink_inet.cc` change the new test fails (2 of 32 assertions: 
`8099 == 80`, `44399 == 443`). With it, all 32 pass.
   - Full `test_tscore` passes (97 test cases) and `make check` passes with 0 
failures.
   - Changed files are clean under 9.2.x's clang-format 10.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to