Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tor Trac #32363]: Check for leading zeros in tor_inet_aton() #1639

Closed
wants to merge 5 commits into from

Conversation

Labels
None yet
Projects
None yet
4 participants
@neelchauhan
Copy link
Contributor

@neelchauhan neelchauhan commented Jan 7, 2020

Ticket: https://trac.torproject.org/projects/tor/ticket/32363

@coveralls
Copy link

@coveralls coveralls commented Jan 7, 2020

Pull Request Test Coverage Report for Build 7853

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4111 unchanged lines in 31 files lost coverage.
  • Overall coverage increased (+0.2%) to 63.333%

Files with Coverage Reduction New Missed Lines %
src/core/mainloop/mainloop.c 1 37.55%
src/core/or/channeltls.c 1 42.54%
src/feature/hs/hs_circuit.c 2 41.57%
src/core/mainloop/connection.h 3 50.0%
src/feature/client/transports.c 3 52.95%
src/feature/dirauth/authmode.c 5 66.67%
src/feature/nodelist/nodelist.c 5 71.36%
src/feature/nodelist/fmt_routerstatus.c 11 82.35%
src/app/main/main.c 15 22.04%
src/feature/dirauth/bwauth.c 15 89.53%
Totals Coverage Status
Change from base Build 7691: 0.2%
Covered Lines: 49954
Relevant Lines: 78875

💛 - Coveralls

* Also, the tor_sscanf() call above prevents an overflow from occuring. */
for (size_t idx = 0; idx <= strlen(str); idx++) {
if (str[idx] == '.' || idx == strlen(str)) {
if (strlen(octet) > 1 && octet[0] == '0')
Copy link
Contributor

@dgoulet-tor dgoulet-tor Jan 7, 2020

octet contains junk at the start of the loop so what happens if we end up here at the first iteration where octet was never set?

Copy link
Contributor Author

@neelchauhan neelchauhan Jan 7, 2020

The tor_sscanf() check should prevent this.

Copy link
Contributor

@dgoulet-tor dgoulet-tor Jan 14, 2020

Ok I think I know what you mean as in we can only get in that if() with a malformed address and the sscanf doesn't allow that.

I would really love to still do have char octet[4] = {0}; just for safety and future proofing this. As in setting it to zeroes at first.

@torproject-pusher torproject-pusher deleted the branch torproject:master May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment