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

--psize option to randomize packet size #475

Open
yvs2014 opened this issue May 23, 2023 · 0 comments
Open

--psize option to randomize packet size #475

yvs2014 opened this issue May 23, 2023 · 0 comments

Comments

@yvs2014
Copy link

yvs2014 commented May 23, 2023

there's some error in signed/unsigned integer comparison which blocks packetsize randomizing:

$ sudo ./mtr --psize=-100 localhost
./mtr: invalid argument: '-100'

possible fix

--- a/ui/utils.c
+++ b/ui/utils.c
@@ -87 +87 @@ int strtonum_or_err(
-                if (num < INT_MAX)
+                if (((long)num) < INT_MAX)

yvs2014@c6a53de

then, it's good to limit possible values of 'psize' because

$ sudo ./mtr --psize=-28 localhost
floating point exception  sudo ./mtr --psize=-28 localhost

possible fix with

+            if (abs(ctl->cpacketsize) <= MINPACKET) {
+                ctl->cpacketsize = (ctl->cpacketsize > 0) ? (MINPACKET + 1) : -(MINPACKET + 1);
+            } else if (abs(ctl->cpacketsize) > MAXPACKET) {
+                ctl->cpacketsize = (ctl->cpacketsize > 0) ? MAXPACKET : -MAXPACKET;
+            }

yvs2014@34ea504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant