]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
fix: avoid undefined behavior in random seed 574/head
authorAaron Lipinski <aaron.lipinski@roboticsplus.co.nz>
Thu, 7 May 2026 19:45:01 +0000 (23:45 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Thu, 7 May 2026 19:45:01 +0000 (23:45 +0400)
ui/mtr.c

index 6886bce346c52adb60868055f9331c567dcf4e14..38146210c4f26253a223d6c228797f73adcb72db 100644 (file)
--- a/ui/mtr.c
+++ b/ui/mtr.c
@@ -712,7 +712,7 @@ static void init_rand(
     struct timeval tv;
 
     gettimeofday(&tv, NULL);
-    srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
+    srand(((getpid() & 0xffff) << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
 }
 
 /*