tag 300273 patch
thanks

On Tue, Oct 04, 2005 at 09:39:36AM +0200, Alberto Gonzalez Iniesta wrote:
> On Thu, Sep 29, 2005 at 11:26:26PM -0400, Justin Pryzby wrote:
> > Comments on this bug?
> 
> I'm pretty busy right now and this is far from important[1], so unless
> someone sends me a nice patch to fix it I don't think this will change
> from his current state :)
Attached.

-- 
Clear skies,
Justin
--- commands.cc 2005-10-04 13:07:20.000000000 -0400
+++ commands.cc.new     2005-10-04 13:07:05.000000000 -0400
@@ -1747,8 +1747,22 @@
        if (*portp == '-') {
            portp++;
            telnetport = 1;
-       } else
+       } else {
            telnetport = 0;
+           if (*portp >='0' && *portp<='9') {
+              char *end;
+              long int p;
+
+              p=strtol(portp, &end, 10);
+              if (ERANGE==errno && (LONG_MIN==p || LONG_MAX==p)) {
+                 fprintf(stderr, "telnet: port %s overflows\n", portp);
+                 return 0;
+              } else if (p<=0 || p>=65536) {
+                 fprintf(stderr, "telnet: port %s out of range\n", portp);
+                 return 0;
+              }
+           }
+       }
     }
     else {
        portp = "telnet";
@@ -1774,7 +1788,7 @@
        if (res < 0)
            return 0;
     }
-        
+
     /* Resolve both the host and service simultaneously. */
     res = getaddrinfo(resolv_hostp, portp, &hints, &hostaddr);
     if (res == EAI_NONAME) {

Reply via email to