This bug was introduced in in 0.2.1.5-alpha, when tor_addr_lookup() was called tor_addr_port_parse().
The first commit fixes the bug, the next two commits refactor the code so the logic is clearer. I split tor_addr_lookup() into 3 separate functions as part of the refactor, the split gets rid of a practracker exception.
This bug was introduced in in 0.2.1.5-alpha, when tor_addr_lookup() was called tor_addr_port_parse().
The first commit fixes the bug, the next two commits refactor the code so the logic is clearer. I split tor_addr_lookup() into 3 separate functions as part of the refactor, the split gets rid of a practracker exception.
This change will break some rare, invalid tor configs, so we can't backport it.
Thanks! This looks good by visual inspection. The commit structure is helpful. The first commit could use a few minor changes:
Add a changes file
Maybe add unit tests to ensure that IPv4 addresses with square brackets get rejected?
This bug was introduced in in 0.2.1.5-alpha, when tor_addr_lookup() was called tor_addr_port_parse().
The first commit fixes the bug, the next two commits refactor the code so the logic is clearer. I split tor_addr_lookup() into 3 separate functions as part of the refactor, the split gets rid of a practracker exception.
This change will break some rare, invalid tor configs, so we can't backport it.
Thanks! This looks good by visual inspection. The commit structure is helpful. The first commit could use a few minor changes:
Thanks! The new tests look reasonable. I wonder if it's necessary to make all those multi-statement macro definitions, instead of helper functions (and maybe much smaller macros that call those functions)? I think helper function would be a little cleaner. Please let me know what you think.
Thanks! The new tests look reasonable. I wonder if it's necessary to make all those multi-statement macro definitions, instead of helper functions (and maybe much smaller macros that call those functions)? I think helper function would be a little cleaner. Please let me know what you think.
The problem with helper functions is that failures are attributed to the test assertions in the helper function, without any context. So it's very hard to tell which test data caused the failure.
I'm not sure if there is some way of providing context as part of the test macros. I suggest that we merge this code as-is, because it's functional, adds coverage, and makes sure we won't introduce future bugs. Then we can open a ticket for follow-up.
Thanks! The new tests look reasonable. I wonder if it's necessary to make all those multi-statement macro definitions, instead of helper functions (and maybe much smaller macros that call those functions)? I think helper function would be a little cleaner. Please let me know what you think.
The problem with helper functions is that failures are attributed to the test assertions in the helper function, without any context. So it's very hard to tell which test data caused the failure.
I'm not sure if there is some way of providing context as part of the test macros. I suggest that we merge this code as-is, because it's functional, adds coverage, and makes sure we won't introduce future bugs. Then we can open a ticket for follow-up.
I see. I agree we should open a new ticket to follow up, in that case.
I think I see that the problem is buried in the TT_DECLARE() macro in tinytest_macros.h. I think it's possible to work around it, but it might be nontrivial. (Rough sketch: redefine TT_DECLARE() in helper functions to read file and line info from function parameters, and make file and line numbers explicit parameters to helper functions.)
Thanks! The new tests look reasonable. I wonder if it's necessary to make all those multi-statement macro definitions, instead of helper functions (and maybe much smaller macros that call those functions)? I think helper function would be a little cleaner. Please let me know what you think.
The problem with helper functions is that failures are attributed to the test assertions in the helper function, without any context. So it's very hard to tell which test data caused the failure.
I'm not sure if there is some way of providing context as part of the test macros. I suggest that we merge this code as-is, because it's functional, adds coverage, and makes sure we won't introduce future bugs. Then we can open a ticket for follow-up.
I see. I agree we should open a new ticket to follow up, in that case.
I think I see that the problem is buried in the TT_DECLARE() macro in tinytest_macros.h. I think it's possible to work around it, but it might be nontrivial. (Rough sketch: redefine TT_DECLARE() in helper functions to read file and line info from function parameters, and make file and line numbers explicit parameters to helper functions.)
I opened #30968 (moved) with your suggestion, and my alternate suggestion (a format string that allows us to print the data being tested).