From 62ef308e6e255bdc55e2f57c746c14b80b86ebad Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 1 May 2001 22:46:11 +0000 Subject: [PATCH] cmds.c: fix broken port number check git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13225 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/gssftp/ftp/ChangeLog | 6 ++++++ src/appl/gssftp/ftp/cmds.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/appl/gssftp/ftp/ChangeLog b/src/appl/gssftp/ftp/ChangeLog index 7c915b1a7..ba6f78147 100644 --- a/src/appl/gssftp/ftp/ChangeLog +++ b/src/appl/gssftp/ftp/ChangeLog @@ -1,3 +1,9 @@ +2001-05-01 Ken Raeburn + + * cmds.c (setpeer): Port number should be unsigned short. (Patch + from Garry Zacheiss.) Add upper-bound check in case short is not + exactly 16 bits. Don't truncate the port number before checking. + 2001-04-27 Ezra Peisach * ftp_var.h: Prototype for recvrequest() needs volatile diff --git a/src/appl/gssftp/ftp/cmds.c b/src/appl/gssftp/ftp/cmds.c index 40eff2d3f..f0f26df67 100644 --- a/src/appl/gssftp/ftp/cmds.c +++ b/src/appl/gssftp/ftp/cmds.c @@ -141,7 +141,7 @@ void setpeer(argc, argv) char *argv[]; { char *host, *hookup(); - short port; + unsigned short port; if (connected) { printf("Already connected to %s, use close first.\n", @@ -158,14 +158,14 @@ void setpeer(argc, argv) } port = sp->s_port; if (argc > 2) { - port = atoi(argv[2]); - if (port <= 0) { + int iport = atoi (argv[2]); + if (iport <= 0 || iport >= 65536) { printf("%s: bad port number-- %s\n", argv[1], argv[2]); printf ("usage: %s host-name [port]\n", argv[0]); code = -1; return; } - port = htons(port); + port = htons(iport); } host = hookup(argv[1], port); if (host) { -- 2.26.2