-
Notifications
You must be signed in to change notification settings - Fork 291
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
Network cleanup: reduce dependency on system-defined constants #515
Conversation
I think splitting in two or three parts would be appropriate, because right now it is huge. |
@sudden6 Done |
Any idea why that failed https://travis-ci.org/TokTok/c-toxcore/jobs/211243880#L2144 ? |
osx is still broken :/ |
@sudden6 Sorry, my mistake. Should be fixed now |
Reviewed 20 of 20 files at r1, 1 of 2 files at r2. toxcore/LAN_discovery.c, line 250 at r2 (raw file):
Please add a comment for those "magic numbers", like in ipv6 toxcore/LAN_discovery.c, line 255 at r2 (raw file):
Same Comments from Reviewable |
Reviewed 3 of 3 files at r3. Comments from Reviewable |
Reviewed 7 of 7 files at r4. Comments from Reviewable |
Review status: all files reviewed at latest revision, 2 unresolved discussions. toxcore/LAN_discovery.c, line 250 at r2 (raw file): Previously, sudden6 wrote…
Moved to const toxcore/LAN_discovery.c, line 255 at r2 (raw file): Previously, sudden6 wrote…
Done. Comments from Reviewable |
@nurupo Can you take a look? |
Sure, when I get time for it. Have been busy the entire week, haven't even joined IRC in a while now. |
Please enable the checkbox "Allow edits from maintainers." on the bottom right. |
Reviewed 11 of 20 files at r1, 3 of 7 files at r4, 6 of 6 files at r5. Comments from Reviewable |
toxcore/network.c, line 144 at r5 (raw file):
Shouldn't constants be in ALL_CAPS? Comments from Reviewable |
I just quickly eyeballed the PR, without reading too much into it. A few questions popped up, which I commented on. Reviewed 11 of 20 files at r1, 3 of 7 files at r4, 6 of 6 files at r5. auto_tests/dht_test.c, line 100 at r5 (raw file):
Did you remove the file which defines auto_tests/network_test.c, line 74 at r5 (raw file):
Hm, so you use auto_tests/TCP_test.c, line 37 at r5 (raw file):
Shouldn't we use toxcore/DHT.c, line 269 at r5 (raw file):
Not toxcore/DHT.c, line 303 at r5 (raw file):
Not Comments from Reviewable |
Review status: 11 of 20 files reviewed at latest revision, 6 unresolved discussions. auto_tests/dht_test.c, line 100 at r5 (raw file): Previously, nurupo wrote…
IDK how you find auto_tests/network_test.c, line 74 at r5 (raw file): Previously, nurupo wrote…
Done. auto_tests/TCP_test.c, line 37 at r5 (raw file): Previously, nurupo wrote…
Done. toxcore/DHT.c, line 269 at r5 (raw file): Previously, nurupo wrote…
toxcore/DHT.c, line 303 at r5 (raw file): Previously, nurupo wrote…
Same as above toxcore/network.c, line 144 at r5 (raw file): Previously, nurupo wrote…
Done. Comments from Reviewable |
Review status: 11 of 20 files reviewed at latest revision, 6 unresolved discussions. auto_tests/dht_test.c, line 100 at r5 (raw file): Previously, Diadlo (Polshakov Dmitry) wrote…
You misunderstood me. I didn't find Comments from Reviewable |
Review status: 11 of 20 files reviewed at latest revision, 6 unresolved discussions. auto_tests/dht_test.c, line 100 at r5 (raw file): Previously, nurupo wrote…
Yes. AF_INET6 is still in the scope Comments from Reviewable |
Reviewed 6 of 9 files at r7, 8 of 8 files at r8. toxcore/network.h, line 187 at r8 (raw file):
Why is this needed? Doesn't seem like this helps with anything. Comments from Reviewable |
Review status: all files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. toxcore/Messenger.c, line 2531 at r7 (raw file): Previously, nurupo wrote…
Done. toxcore/network.h, line 187 at r8 (raw file): Previously, nurupo wrote…
Comments from Reviewable |
Review status: 19 of 20 files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. toxcore/network.h, line 187 at r8 (raw file): Previously, Diadlo (Polshakov Dmitry) wrote…
Then add asserts in Comments from Reviewable |
Review status: 18 of 20 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. toxcore/network.h, line 187 at r8 (raw file): Previously, nurupo wrote…
Replaced on constants Comments from Reviewable |
@nurupo Forget, that |
@nurupo ping №2 |
Review status: 18 of 20 files reviewed at latest revision, 1 unresolved discussion. toxcore/network.h, line 187 at r8 (raw file): Previously, Diadlo (Polshakov Dmitry) wrote…
Why were the values changed, 16 to 22 and 46 to 66? Did the compilation started to fail once you have added the compile-time checks against systems constants? Comments from Reviewable |
Review status: 18 of 20 files reviewed at latest revision, 1 unresolved discussion. toxcore/network.h, line 187 at r8 (raw file): Previously, nurupo wrote…
Exectly. And I have done binary search for the right value Comments from Reviewable |
Reviewed 2 of 2 files at r9. toxcore/network.h, line 187 at r8 (raw file): This shows that assuming things in C is dangerous. While 16 and 46 look perfectly fine for the
so it could potentially have written 22 or 66 bytes on your system, which would result in a buffer overflow, which is why I said that it's something we have to check. toxcore/onion.c, line 83 at r9 (raw file):
Hm, weird, shouldn't this function succeed for @Diadlo, it's not an issue with your PR but with the original code. Comments from Reviewable |
Please rebase on master. In 889d25f, I have edited |
@nurupo Thank you for reminding! Done |
Check Travis, looks like it fails to build on FreeBSD. |
You could move changes from 889d25f to |
@nurupo Done |
Looks good to me. Would still like to see @irungentoo answer my question, but don't let that block the PR from being merged. Reviewed 1 of 1 files at r10, 1 of 1 files at r11. Comments from Reviewable |
Reviewed 1 of 8 files at r6, 6 of 9 files at r7, 7 of 8 files at r8, 2 of 2 files at r9, 1 of 1 files at r10, 1 of 1 files at r11. toxcore/network.c, line 161 at r11 (raw file):
greater or equal toxcore/network.c, line 975 at r11 (raw file):
Comments from Reviewable |
Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. toxcore/network.c, line 161 at r11 (raw file): Previously, robinlinden (Robin Lindén) wrote…
Done. toxcore/network.c, line 975 at r11 (raw file): Previously, robinlinden (Robin Lindén) wrote…
Done. toxcore/onion.c, line 83 at r9 (raw file): Previously, nurupo wrote…
It will succeed. It shouldn't? Comments from Reviewable |
Reviewed 1 of 1 files at r13. Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. toxcore/onion.c, line 83 at r9 (raw file): Previously, Diadlo (Polshakov Dmitry) wrote…
No, it won't succeed, the function will return with It just seems weird that the second if condition: if (target->family == TOX_AF_INET || target->family == TOX_TCP_INET) {
memcpy(target->ip4.uint8, data + 1, SIZE_IP4);
} else {
memcpy(target->ip6.uint8, data + 1, SIZE_IP6);
} does accept bool valid = disable_family_check ||
target->family == TOX_AF_INET ||
target->family == TOX_AF_INET6;
return valid ? 0 : -1; So, to reiterate, I'm getting mixed signals here. It looks like the function should succeed for Comments from Reviewable |
@nurupo I think, it should be changed in another PR, because refactoring should not touch the logic |
I'm not asking to change it. You must have misunderstood me. |
Should be the last part of network cleanup. I can split it on few PRs if it's needed.
This change is