Context diffs are fine. You missed a couple of places, but I think I got them
all now.

On Thu, 13 Apr 2000, Paul Jimenez wrote:
> On Thursday, Apr 13, 2000, Oskar Sandberg writes:
> >
> >Yeah, the casting on the port is wrong, somebody is guilty having decided to
> >use a signed short for it, when really at least an unsigned short is needed. 
> >I
> >never got around to fixing it because the short is used in bunch of places.
> >Feel free to do so yourself.
> >
> >AFAIK 77777 is illegal though.
> 
> Well, I decided to take a small swing at fixing this; part of the following 
> patch
> removes the cast to short since it seems to be unnecessary. The other part
> adds some range checking to tcpAddress.port. 
> 
> Uh, I guess I should ask what format people want patches in; are context
> diffs okay?  That's what you're getting this time at least...
> 
>    --pj
> 
> diff -c -r1.5 tcpAddress.java
> *** tcpAddress.java     2000/03/29 18:49:13     1.5
> --- tcpAddress.java     2000/04/13 19:08:33
> ***************
> *** 30,46 ****
>     /** The port number that the client is listening to **/
>     public int port;
> 
> !   public tcpAddress(InetAddress i, int portnum)
>       {
>         host = i;
> !       port = portnum;
>       }
> 
>     public tcpAddress(String ip, int portnum)
> !     throws UnknownHostException
>       {
>         host = InetAddress.getByName(ip);
> !       port = portnum;
>       }
> 
>     /** Creates an address from a string in the format "a.b.c.d:p" **/
> --- 30,47 ----
>     /** The port number that the client is listening to **/
>     public int port;
> 
> !   public tcpAddress(InetAddress i, int portnum)
> !     throws IllegalArgumentException
>       {
>         host = i;
> !       setPort(portnum);
>       }
> 
>     public tcpAddress(String ip, int portnum)
> !     throws IllegalArgumentException, UnknownHostException
>       {
>         host = InetAddress.getByName(ip);
> !       setPort(portnum);
>       }
> 
>     /** Creates an address from a string in the format "a.b.c.d:p" **/
> ***************
> *** 50,56 ****
>         int i=str.indexOf(':');
>         if(i==-1) throw new IllegalArgumentException();
>         host=InetAddress.getByName(str.substring(0,i));
> !       port=new Integer(str.substring(i+1)).intValue();
>       }
> 
>       public ProtocolListeningAddress listenPart()
> --- 51,57 ----
>         int i=str.indexOf(':');
>         if(i==-1) throw new IllegalArgumentException();
>         host=InetAddress.getByName(str.substring(0,i));
> !       setPort(new Integer(str.substring(i+1)).intValue());
>       }
> 
>       public ProtocolListeningAddress listenPart()
> ***************
> *** 75,78 ****
> --- 76,87 ----
>         return ((o instanceof tcpAddress) &&
>                 ((tcpAddress) o).host.equals(host));
>       }
> +
> +   public void setPort(int portnum) throws IllegalArgumentException
> +   {
> +      if ((portnum <0) || (portnum >65535)) {
> +          throw new IllegalArgumentException();
> +      }
> +      port=portnum;
> +   }
>   }
> 
> _______________________________________________
> Freenet-dev mailing list
> Freenet-dev at lists.sourceforge.net
> http://lists.sourceforge.net/mailman/listinfo/freenet-dev
-- 

Oskar Sandberg

md98-osa at nada.kth.se

#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

_______________________________________________
Freenet-dev mailing list
Freenet-dev at lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/freenet-dev

Reply via email to