mtr
mtr copied to clipboard
--psize option to randomize packet size
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)
https://github.com/yvs2014/mtr085/commit/c6a53de814bd8030381e9b7e30f6799ddf4963f4
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;
+ }
https://github.com/yvs2014/mtr085/commit/34ea504a3bb2acc50560063dece653ee88e912b4