[PATCH] debuginfod: Disallow --port=0.

Mark Wielaard mark@klomp.org
Fri Mar 27 14:52:34 GMT 2020


When starting debuginfod with --port=0 it would start using a random port
(possibly different for ipv4 and ipv6). This seems to be an accidental
and not very useful functionality. Just produce an error when started
with --port=0.

https://sourceware.org/bugzilla/show_bug.cgi?id=25728

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 debuginfod/ChangeLog      | 4 ++++
 debuginfod/debuginfod.cxx | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 58ba85cf..018d62f6 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,7 @@
+2020-03-27  Mark Wielaard  <mark@klomp.org>
+
+	* debuginfod.cxx (parse_opt): Check port is not zero.
+
 2020-03-26  Frank Ch. Eigler <fche@redhat.com>
 
 	* debuginfod.cxx (parse_opt): For -U, prefer dpkg-deb
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 9e8d5560..84eeb78d 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -422,7 +422,8 @@ parse_opt (int key, char *arg,
     case 'v': verbose ++; break;
     case 'd': db_path = string(arg); break;
     case 'p': http_port = (unsigned) atoi(arg);
-      if (http_port > 65535) argp_failure(state, 1, EINVAL, "port number");
+      if (http_port == 0 || http_port > 65535)
+        argp_failure(state, 1, EINVAL, "port number");
       break;
     case 'F': scan_files = true; break;
     case 'R':
-- 
2.18.2



More information about the Elfutils-devel mailing list