]> Zhao Yanbai Git Server - minix.git/commitdiff
improved tcp_acceptto.
authorPhilip Homburg <philip@cs.vu.nl>
Fri, 17 Feb 2006 13:47:31 +0000 (13:47 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Fri, 17 Feb 2006 13:47:31 +0000 (13:47 +0000)
servers/inet/generic/tcp.c

index f7cee644f525bd05343ed4da48f77e085d340cbc..04b888ece8e3358786c69787fe97312469fb2d84 100644 (file)
@@ -2247,6 +2247,7 @@ tcp_fd_t *tcp_fd;
        tcp_conn_t *tcp_conn;
        tcp_cookie_t *cookiep;
        acc_t *data;
+       tcp_cookie_t cookie;
 
        if (!(tcp_fd->tf_flags & TFF_LISTENQ))
        {
@@ -2272,11 +2273,13 @@ tcp_fd_t *tcp_fd;
 
        data= bf_packIffLess(data, sizeof(*cookiep));
        cookiep= (tcp_cookie_t *)ptr2acc_data(data);
+       cookie= *cookiep;
 
-       dst_nr= cookiep->tc_ref;
+       bf_afree(data); data= NULL;
+
+       dst_nr= cookie.tc_ref;
        if (dst_nr < 0 || dst_nr >= TCP_FD_NR)
        {
-               bf_afree(data); data= NULL;
                printf("tcp_acceptto: bad fd %d\n", dst_nr);
                tcp_reply_ioctl(tcp_fd, EINVAL);
                return NW_OK;
@@ -2287,21 +2290,17 @@ tcp_fd_t *tcp_fd;
                dst_fd->tf_conn != NULL ||
                !(dst_fd->tf_flags & TFF_COOKIE))
        {
-               bf_afree(data); data= NULL;
                printf("tcp_acceptto: bad flags 0x%x or conn %p for fd %d\n",
                        dst_fd->tf_flags, dst_fd->tf_conn, dst_nr);
                tcp_reply_ioctl(tcp_fd, EINVAL);
                return NW_OK;
        }
-       if (memcmp(cookiep, &dst_fd->tf_cookie, sizeof(*cookiep)) != 0)
+       if (memcmp(&cookie, &dst_fd->tf_cookie, sizeof(cookie)) != 0)
        {
-               bf_afree(data); data= NULL;
                printf("tcp_acceptto: bad cookie\n");
                return NW_OK;
        }
 
-       bf_afree(data); data= NULL;
-
        /* Move connection */
        tcp_fd->tf_listenq[i]= NULL;
        tcp_conn->tc_fd= dst_fd;