Hello Ted,

On 4 Jun 2016, at 20:28, Ted Unangst wrote:

[email protected] wrote:
Since revision 1.15 at http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/bind/bin/dig/dig.c, dig ignores the -p option and instead sends to 53. I understand how support for pledge() makes it impossible to support -p, however, just ignoring the argument leads to several painful potential failure modes.

How-To-Repeat:
$ dig -p 5300 www.example.com @localhost
;; Warning, -p option ignored

This should work a little better.


Index: dig.c
===================================================================
RCS file: /cvs/src/usr.sbin/bind/bin/dig/dig.c,v
retrieving revision 1.16
diff -u -p -r1.16 dig.c
--- dig.c       11 Nov 2015 02:52:46 -0000      1.16
+++ dig.c       4 Jun 2016 18:28:08 -0000
@@ -1192,8 +1192,10 @@ dash_option(char *option, char *next, di
                strlcpy(keyfile, value, sizeof(keyfile));
                return (value_from_next);
        case 'p':
-               fprintf(stderr, ";; Warning, -p option ignored\n");
-               /* port = (in_port_t) parse_uint(value, "port number", 
MAXPORT); */
+               if (parse_uint(value, "port number", MAXPORT) != 53) {
+                       fprintf(stderr, ";; Error, only port 53 supported\n");
+                       exit(1);
+               }
                return (value_from_next);
        case 'q':
                if (!config_only) {

Did not test it but yes, that should do!

Maybe while you’re at it, also remove/update this line (line 152) from dig.c:

"                 -p port             (specify port number)\n"

I notice the man page did get that change.

Kind regards,
--
Peter van Dijk
PowerDNS.COM BV - https://www.powerdns.com/

Reply via email to