Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (22 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libjava/java/net/SocketPermission.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* SocketPermission.java -- Class modeling permissions for socket operations
    2    Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
     2   Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
    33
    44This file is part of GNU Classpath.
     
    3838package java.net;
    3939
     40
    4041import java.security.Permission;
    4142import java.security.PermissionCollection;
     
    8889 *   Can connect to or accept connections from www.urbanophile.com on port 80
    8990 * SocketPermission("localhost:1024-", "listen,accept,connect");
    90  *   Can connect to, accept from, an listen on any local port number 1024 and up.
     91 *   Can connect to, accept from, an listen on any local port number 1024
     92 *   and up.
    9193 * SocketPermission("*.edu", "connect");
    9294 *   Can connect to any host in the edu domain
     
    100102 */
    101103public final class SocketPermission extends Permission
    102   implements java.io.Serializable
     104  implements Serializable
    103105{
     106
    104107
    105108// FIXME: Needs serialization work, including readObject/writeObject methods.
     
    119122   *
    120123   * @param hostport The hostname/port number combination
    121    * @param perms The actions string
     124   * @param s The actions string
    122125   */
    123126  public SocketPermission(String hostport, String actions)
     
    164167  {
    165168    int hash = 100;
    166 
    167     // FIXME: Get a real hash function
    168     for (int i = 0; i < hostport.length(); i++)
    169       hash = hash + (int) hostport.charAt(i) * 7;
    170 
    171     return (hash);
     169    if (hostport != null)
     170      hash += hostport.hashCode();
     171    if (actions != null)
     172      hash += actions.hashCode();
     173    return hash;
    172174  }
    173175
     
    242244   * <li>The argument's hostname or IP address is equal to this object's.
    243245   * <li>The argument's canonical hostname is equal to this object's.
    244    * <li>The argument's canonical name matches this domains hostname with wildcards
     246   * <li>The argument's canonical name matches this domains hostname with
     247   * wildcards
    245248   * </ul>
    246249   *
     
    274277    if (hostport.indexOf(":") == -1)
    275278      {
    276         ourfirstport = 0;
    277         ourlastport = 65535;
    278       }
    279     else
    280       {
    281         // FIXME:  Needs bulletproofing.
    282         // This will dump if hostport if all sorts of bad data was passed to
    283         // the constructor
    284         String range = hostport.substring(hostport.indexOf(":") + 1);
    285         if (range.startsWith("-"))
    286           ourfirstport = 0;
    287         else if (range.indexOf("-") == -1)
    288           ourfirstport = Integer.parseInt(range);
    289         else
    290           ourfirstport =
    291             Integer.parseInt(range.substring(0, range.indexOf("-")));
    292 
    293         if (range.endsWith("-"))
    294           ourlastport = 65535;
    295         else if (range.indexOf("-") == -1)
    296           ourlastport = Integer.parseInt(range);
    297         else
    298           ourlastport =
    299             Integer.parseInt(range.
    300                              substring(range.indexOf("-") + 1,
    301                                        range.length()));
     279ourfirstport = 0;
     280ourlastport = 65535;
     281      }
     282    else
     283      {
     284// FIXME:  Needs bulletproofing.
     285// This will dump if hostport if all sorts of bad data was passed to
     286// the constructor
     287String range = hostport.substring(hostport.indexOf(":") + 1);
     288if (range.startsWith("-"))
     289  ourfirstport = 0;
     290else if (range.indexOf("-") == -1)
     291  ourfirstport = Integer.parseInt(range);
     292else
     293  ourfirstport =
     294    Integer.parseInt(range.substring(0, range.indexOf("-")));
     295
     296if (range.endsWith("-"))
     297  ourlastport = 65535;
     298else if (range.indexOf("-") == -1)
     299  ourlastport = Integer.parseInt(range);
     300else
     301  ourlastport =
     302    Integer.parseInt(range.
     303     substring(range.indexOf("-") + 1,
     304       range.length()));
    302305      }
    303306
     
    305308    if (p.hostport.indexOf(":") == -1)
    306309      {
    307         theirfirstport = 0;
    308         ourlastport = 65535;
    309       }
    310     else
    311       {
    312         // This will dump if hostport if all sorts of bad data was passed to
    313         // the constructor
    314         String range = p.hostport.substring(hostport.indexOf(":") + 1);
    315         if (range.startsWith("-"))
    316           theirfirstport = 0;
    317         else if (range.indexOf("-") == -1)
    318           theirfirstport = Integer.parseInt(range);
    319         else
    320           theirfirstport =
    321             Integer.parseInt(range.substring(0, range.indexOf("-")));
    322 
    323         if (range.endsWith("-"))
    324           theirlastport = 65535;
    325         else if (range.indexOf("-") == -1)
    326           theirlastport = Integer.parseInt(range);
    327         else
    328           theirlastport =
    329             Integer.parseInt(range.
    330                              substring(range.indexOf("-") + 1,
    331                                        range.length()));
     310theirfirstport = 0;
     311ourlastport = 65535;
     312      }
     313    else
     314      {
     315// This will dump if hostport if all sorts of bad data was passed to
     316// the constructor
     317String range = p.hostport.substring(hostport.indexOf(":") + 1);
     318if (range.startsWith("-"))
     319  theirfirstport = 0;
     320else if (range.indexOf("-") == -1)
     321  theirfirstport = Integer.parseInt(range);
     322else
     323  theirfirstport =
     324    Integer.parseInt(range.substring(0, range.indexOf("-")));
     325
     326if (range.endsWith("-"))
     327  theirlastport = 65535;
     328else if (range.indexOf("-") == -1)
     329  theirlastport = Integer.parseInt(range);
     330else
     331  theirlastport =
     332    Integer.parseInt(range.
     333     substring(range.indexOf("-") + 1,
     334       range.length()));
    332335      }
    333336
     
    359362    try
    360363      {
    361         ourcanonical = InetAddress.getByName(ourhost).getHostName();
    362         theircanonical = InetAddress.getByName(theirhost).getHostName();
     364ourcanonical = InetAddress.getByName(ourhost).getHostName();
     365theircanonical = InetAddress.getByName(theirhost).getHostName();
    363366      }
    364367    catch (UnknownHostException e)
    365368      {
    366         // Who didn't resolve?  Just assume current address is canonical enough
    367         // Is this ok to do?
    368         if (ourcanonical == null)
    369           ourcanonical = ourhost;
    370         if (theircanonical == null)
    371           theircanonical = theirhost;
     369// Who didn't resolve?  Just assume current address is canonical enough
     370// Is this ok to do?
     371if (ourcanonical == null)
     372  ourcanonical = ourhost;
     373if (theircanonical == null)
     374  theircanonical = theirhost;
    372375      }
    373376
     
    378381    if (ourhost.indexOf("*.") != -1)
    379382      {
    380         String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
    381         if (theircanonical.endsWith(wild_domain))
    382           return (true);
     383String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
     384if (theircanonical.endsWith(wild_domain))
     385  return (true);
    383386      }
    384387
Note: See TracChangeset for help on using the changeset viewer.