Patch to improve -p error message.

Kevin Steves stevesk at pobox.com
Mon Jan 15 10:56:17 EST 2001


you can still enter -4501, which is invalid and not noted, or 4501L
which will work but may not be what you wanted.  if you want to clean up
atoi() handling you might sweep the tree (scp has -P till exempel) and
see how head.c from openbsd uses strtol() in a paranoid fashion.

On Wed, 10 Jan 2001, Mo DeJong wrote:
: I got sick of getting a lame error message when I typed
: the wrong thing in for a -p argument, so I wrote
: up this patch.
: 
: Bad:
: 
: % ssh -p L4501 localhost
: Secure connection to localhost refused.
: 
: Good:
: 
: ./ssh -p L4501 localhost
: Bad port specification 'L4501'.
: 
: Mo DeJong
: Red Hat Inc
: 
: Index: ssh.c
: ===================================================================
: RCS file: /cvs/openssh_cvs/ssh.c,v
: retrieving revision 1.56
: diff -u -r1.56 ssh.c
: --- ssh.c       2000/12/28 16:40:05     1.56
: +++ ssh.c       2001/01/11 06:01:18
: @@ -437,6 +437,12 @@
:                         break;
:                 case 'p':
:                         options.port = atoi(optarg);
: +                       if (options.port == 0) {
: +                           fprintf(stderr,
: +                               "Bad port specification '%s'.\n",
: +                                   optarg);
: +                           exit(1);
: +                       }
:                         break;
:                 case 'l':
:                         options.user = optarg;






More information about the openssh-unix-dev mailing list