VirtualBox

Changeset 1010 in vbox


Ignore:
Timestamp:
Feb 21, 2007 2:40:16 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18860
Message:

Disable built-in TFTP service in slirp. Needs to be configured properly
before reenabling it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/udp.c

    r184 r1010  
    3838 * Changes and additions relating to SLiRP
    3939 * Copyright (c) 1995 Danny Gasparovski.
    40  * 
    41  * Please read the file COPYRIGHT for the 
     40 *
     41 * Please read the file COPYRIGHT for the
    4242 * terms and conditions of the copyright.
    4343 */
     
    6767        udb.so_next = udb.so_prev = &udb;
    6868}
    69 /* m->m_data  points at ip packet header 
    70  * m->m_len   length ip packet 
     69/* m->m_data  points at ip packet header
     70 * m->m_len   length ip packet
    7171 * ip->ip_len length data (IPDU)
    7272 */
     
    8080/*      struct mbuf *opts = 0;*/
    8181        int len;
    82         struct ip save_ip; 
     82        struct ip save_ip;
    8383        struct socket *so;
    84        
     84
    8585        DEBUG_CALL("udp_input");
    8686        DEBUG_ARG("m = %lx", (long)m);
    8787        DEBUG_ARG("iphlen = %d", iphlen);
    88        
     88
    8989        udpstat.udps_ipackets++;
    9090
     
    120120                ip->ip_len = len;
    121121        }
    122        
     122
    123123        /*
    124124         * Save a copy of the IP header in case we want restore it
    125125         * for sending an ICMP error message in response.
    126126         */
    127         save_ip = *ip; 
     127        save_ip = *ip;
    128128        save_ip.ip_len+= iphlen;         /* tcp_input subtracts this */
    129129
     
    137137          ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
    138138          /* keep uh_sum for ICMP reply
    139            * uh->uh_sum = cksum(m, len + sizeof (struct ip)); 
    140            * if (uh->uh_sum) { 
     139           * uh->uh_sum = cksum(m, len + sizeof (struct ip));
     140           * if (uh->uh_sum) {
    141141           */
    142142          if(cksum(m, len + sizeof(struct ip))) {
     
    154154        }
    155155
     156#ifndef VBOX
     157/* Disable this for now (security leak, allows the guest to read any file
     158 * from the current directory and the directories in it on the host).
     159 * Reenable it after adding a way to optionally configure the tftp root
     160 * directory (the existing tftp prefix setting is not sufficient). */
    156161        /*
    157162         *  handle TFTP
     
    161166            goto bad;
    162167        }
     168#endif /* !VBOX */
    163169
    164170        /*
     
    169175            so->so_laddr.s_addr != ip->ip_src.s_addr) {
    170176                struct socket *tmp;
    171                
     177
    172178                for (tmp = udb.so_next; tmp != &udb; tmp = tmp->so_next) {
    173179                        if (tmp->so_lport == uh->uh_sport &&
     
    188194                }
    189195        }
    190        
     196
    191197        if (so == NULL) {
    192198          /*
     
    196202          if ((so = socreate()) == NULL) goto bad;
    197203          if(udp_attach(so) == -1) {
    198             DEBUG_MISC((dfd," udp_attach errno = %d-%s\n", 
     204            DEBUG_MISC((dfd," udp_attach errno = %d-%s\n",
    199205                        errno,strerror(errno)));
    200206            sofree(so);
    201207            goto bad;
    202208          }
    203          
     209
    204210          /*
    205211           * Setup fields
     
    208214          so->so_laddr = ip->ip_src;
    209215          so->so_lport = uh->uh_sport;
    210          
     216
    211217          if ((so->so_iptos = udp_tos(so)) == 0)
    212218            so->so_iptos = ip->ip_tos;
    213          
     219
    214220          /*
    215221           * XXXXX Here, check if it's in udpexec_list,
     
    236242          *ip=save_ip;
    237243          DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
    238           icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno)); 
     244          icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
    239245        }
    240246
     
    254260}
    255261
    256 int udp_output2(struct socket *so, struct mbuf *m, 
     262int udp_output2(struct socket *so, struct mbuf *m,
    257263                struct sockaddr_in *saddr, struct sockaddr_in *daddr,
    258264                int iptos)
     
    272278        m->m_data -= sizeof(struct udpiphdr);
    273279        m->m_len += sizeof(struct udpiphdr);
    274        
     280
    275281        /*
    276282         * Fill in mbuf with extended UDP header
     
    301307        ((struct ip *)ui)->ip_ttl = ip_defttl;
    302308        ((struct ip *)ui)->ip_tos = iptos;
    303        
     309
    304310        udpstat.udps_opackets++;
    305        
     311
    306312        error = ip_output(so, m);
    307        
     313
    308314        return (error);
    309315}
    310316
    311 int udp_output(struct socket *so, struct mbuf *m, 
     317int udp_output(struct socket *so, struct mbuf *m,
    312318               struct sockaddr_in *addr)
    313319
     
    323329    daddr.sin_addr = so->so_laddr;
    324330    daddr.sin_port = so->so_lport;
    325    
     331
    326332    return udp_output2(so, m, &saddr, &daddr, so->so_iptos);
    327333}
     
    332338{
    333339  struct sockaddr_in addr;
    334        
     340
    335341  if((so->s = socket(AF_INET,SOCK_DGRAM,0)) != -1) {
    336342    /*
     
    387393{
    388394        int i = 0;
    389        
     395
    390396        while(udptos[i].tos) {
    391397                if ((udptos[i].fport && ntohs(so->so_fport) == udptos[i].fport) ||
     
    396402                i++;
    397403        }
    398        
     404
    399405        return 0;
    400406}
     
    423429        char buff[sizeof(CTL_MSG)];
    424430        u_char type;
    425        
     431
    426432struct talk_request {
    427433        struct talk_request *next;
     
    429435        struct socket *tcp_so;
    430436} *req;
    431        
    432         static struct talk_request *req_tbl = 0;       
    433        
     437
     438        static struct talk_request *req_tbl = 0;
     439
    434440#endif
    435        
     441
    436442struct cu_header {
    437443        uint16_t        d_family;               /* destination family */
     
    460466                if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
    461467                        return;
    462                
     468
    463469#define IS_OLD  (so->so_emu == EMU_TALK)
    464470
     
    483489                        OTOSIN(omsg, ctl_addr)->sin_addr = our_addr;
    484490                        strncpy(omsg->l_name, getlogin(), NAME_SIZE_OLD);
    485                 } else {                /* new talk */ 
     491                } else {                /* new talk */
    486492                        omsg = (CTL_MSG_OLD *) buff;
    487493                        nmsg = mtod(m, CTL_MSG *);
     
    491497                        strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD);
    492498                }
    493                
    494                 if (type == LOOK_UP) 
     499
     500                if (type == LOOK_UP)
    495501                        return;         /* for LOOK_UP this is enough */
    496                        
     502
    497503                if (IS_OLD) {           /* make a copy of the message */
    498504                        COPY_MSG(nmsg, omsg);
     
    513519                 * of the message, one in old talk and one in new talk
    514520                 * format.
    515                  */ 
     521                 */
    516522
    517523                if (type == ANNOUNCE) {
    518524                        int s;
    519525                        u_short temp_port;
    520                        
     526
    521527                        for(req = req_tbl; req; req = req->next)
    522528                                if (so == req->udp_so)
    523529                                        break;          /* found it */
    524                                        
     530
    525531                        if (!req) {     /* no entry for so, create new */
    526532                                req = (struct talk_request *)
    527533                                        malloc(sizeof(struct talk_request));
    528534                                req->udp_so = so;
    529                                 req->tcp_so = solisten(0,               
    530                                         OTOSIN(omsg, addr)->sin_addr.s_addr,   
     535                                req->tcp_so = solisten(0,
     536                                        OTOSIN(omsg, addr)->sin_addr.s_addr,
    531537                                        OTOSIN(omsg, addr)->sin_port,
    532538                                        SS_FACCEPTONCE);
    533539                                req->next = req_tbl;
    534540                                req_tbl = req;
    535                         }                       
    536                        
     541                        }
     542
    537543                        /* replace port number in addr field */
    538544                        addrlen = sizeof(addr);
    539                         getsockname(req->tcp_so->s, 
     545                        getsockname(req->tcp_so->s,
    540546                                        (struct sockaddr *) &addr,
    541                                         &addrlen);             
     547                                        &addrlen);
    542548                        OTOSIN(omsg, addr)->sin_port = addr.sin_port;
    543549                        OTOSIN(omsg, addr)->sin_addr = our_addr;
    544550                        OTOSIN(nmsg, addr)->sin_port = addr.sin_port;
    545                         OTOSIN(nmsg, addr)->sin_addr = our_addr;               
    546                        
     551                        OTOSIN(nmsg, addr)->sin_addr = our_addr;
     552
    547553                        /* send LEAVE_INVITEs */
    548554                        temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
    549555                        OTOSIN(omsg, ctl_addr)->sin_port = 0;
    550556                        OTOSIN(nmsg, ctl_addr)->sin_port = 0;
    551                         omsg->type = nmsg->type = LEAVE_INVITE;                 
    552                        
     557                        omsg->type = nmsg->type = LEAVE_INVITE;
     558
    553559                        s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
    554560                        addr.sin_addr = our_addr;
    555561                        addr.sin_family = AF_INET;
    556562                        addr.sin_port = htons(517);
    557                         sendto(s, (char *)omsg, sizeof(*omsg), 0, 
     563                        sendto(s, (char *)omsg, sizeof(*omsg), 0,
    558564                                (struct sockaddr *)&addr, sizeof(addr));
    559565                        addr.sin_port = htons(518);
     
    562568                        closesocket(s) ;
    563569
    564                         omsg->type = nmsg->type = ANNOUNCE; 
     570                        omsg->type = nmsg->type = ANNOUNCE;
    565571                        OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
    566572                        OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
    567573                }
    568                
    569                 /*     
     574
     575                /*
    570576                 * If it is a DELETE message, we send a copy to the
    571577                 * local daemons. Then we delete the entry corresponding
    572578                 * to our socket from the request table.
    573579                 */
    574                
     580
    575581                if (type == DELETE) {
    576582                        struct talk_request *temp_req, *req_next;
    577583                        int s;
    578584                        u_short temp_port;
    579                        
     585
    580586                        temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
    581587                        OTOSIN(omsg, ctl_addr)->sin_port = 0;
    582588                        OTOSIN(nmsg, ctl_addr)->sin_port = 0;
    583                        
     589
    584590                        s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
    585591                        addr.sin_addr = our_addr;
     
    592598                                (struct sockaddr *)&addr, sizeof(addr));
    593599                        closesocket(s);
    594                        
     600
    595601                        OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
    596602                        OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
     
    615621                        }
    616622                }
    617                
    618                 return;         
     623
     624                return;
    619625#endif
    620                
     626
    621627        case EMU_CUSEEME:
    622        
     628
    623629                /*
    624630                 * Cu-SeeMe emulation.
     
    626632                 * do any other tests, just replace the address and port
    627633                 * fields.
    628                  */ 
     634                 */
    629635                if (m->m_len >= sizeof (*cu_head)) {
    630636                        if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
     
    634640                        cu_head->so_addr = our_addr.s_addr;
    635641                }
    636                
     642
    637643                return;
    638644        }
     
    654660        int opt = 1;
    655661#endif /* VBOX */
    656        
     662
    657663        if ((so = socreate()) == NULL) {
    658664                free(so);
     
    673679        setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
    674680/*      setsockopt(so->s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); */
    675        
     681
    676682        getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
    677683        so->so_fport = addr.sin_port;
     
    680686        else
    681687           so->so_faddr = addr.sin_addr;
    682        
     688
    683689        so->so_lport = lport;
    684690        so->so_laddr.s_addr = laddr;
    685691        if (flags != SS_FACCEPTONCE)
    686692           so->so_expire = 0;
    687        
     693
    688694        so->so_state = SS_ISFCONNECTED;
    689        
     695
    690696        return so;
    691697}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette