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

mtr with unspecified destination #471

Open
yvs2014 opened this issue Apr 25, 2023 · 2 comments
Open

mtr with unspecified destination #471

yvs2014 opened this issue Apr 25, 2023 · 2 comments

Comments

@yvs2014
Copy link

yvs2014 commented Apr 25, 2023

Hello,

accidentally spotted in current version

% sudo ./mtr 0
<many lines with localhost>

non-gtk part probably can be fixed with

diff --git a/ui/net.c b/ui/net.c
index efeb782..2ba94cc 100644
--- a/ui/net.c
+++ b/ui/net.c
@@ -746,13 +746,14 @@ int net_open(
         return err;
     }
 
-    net_reopen(ctl, res);
+    if (net_reopen(ctl, res) != 0)
+      return -1; /* fail */
 
     return 0;
 }
 
 
-void net_reopen(
+int net_reopen(
     struct mtr_ctl *ctl,
     struct addrinfo *res)
 {
@@ -767,6 +768,8 @@ void net_reopen(
     ctl->af = remotesockaddr->sa_family = sourcesockaddr->sa_family = res->ai_family;
     remoteaddress = sockaddr_addr_offset(remotesockaddr);
     memcpy(remoteaddress, sockaddr_addr_offset(res->ai_addr), sockaddr_addr_size(remotesockaddr));
+    if (addrcmp(remoteaddress, &ctl->unspec_addr, ctl->af) == 0)
+        return -1; /* fail */
     inet_ntop(remotesockaddr->sa_family, remoteaddress, remoteaddr, sizeof(remoteaddr));
 
     sourceaddress = sockaddr_addr_offset(sourcesockaddr);
@@ -780,7 +783,7 @@ void net_reopen(
     } else {
         net_find_local_address();
     }
-
+    return 0; /* norm */
 }
 
 
diff --git a/ui/net.h b/ui/net.h
index 354c998..2488d13 100644
--- a/ui/net.h
+++ b/ui/net.h
@@ -34,7 +34,7 @@
 extern int net_open(
     struct mtr_ctl *ctl,
     struct addrinfo *res);
-extern void net_reopen(
+extern int net_reopen(
     struct mtr_ctl *ctl,
     struct addrinfo *res);
 extern void net_reset(
@rewolff
Copy link
Collaborator

rewolff commented Apr 25, 2023

Agreed. Can you create a pull request for me?

@yvs2014
Copy link
Author

yvs2014 commented Apr 25, 2023

Done, but I cannot create the second fork of the same repo.
On copied branch it looks like below
master...yvs2014:mtr085:mtr20230425-unspecaddr

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

2 participants