public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] debuginfod: Disallow --port=0.
Date: Fri, 27 Mar 2020 15:52:34 +0100	[thread overview]
Message-ID: <20200327145234.4624-1-mark@klomp.org> (raw)

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


                 reply	other threads:[~2020-03-27 14:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200327145234.4624-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).