Commit 173c47cd authored by robertdavidgraham's avatar robertdavidgraham
Browse files
parents 696958af 0c600e33
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -439,6 +439,9 @@ receive_thread(struct Masscan *masscan,
            tcpcon_timeouts(tcpcon, secs, usecs);
        }

	if (length > 1514)
		continue;

        /*
         * "Preprocess" the response packet. This means to go through and
         * figure out where the TCP/IP headers are and the locations of
@@ -508,7 +511,7 @@ receive_thread(struct Masscan *masscan,

            if (TCP_IS_SYNACK(px, parsed.transport_offset)) {
                if (syn_hash(ip_them, parsed.port_src) != seqno_me - 1) {
                    LOG(1, "%u.%u.%u.%u - bad cookie: ackno=0x%08x expected=0x%08x\n", 
                    LOG(2, "%u.%u.%u.%u - bad cookie: ackno=0x%08x expected=0x%08x\n", 
                        (ip_them>>24)&0xff, (ip_them>>16)&0xff, (ip_them>>8)&0xff, (ip_them>>0)&0xff, 
                        seqno_me-1, syn_hash(ip_them, parsed.port_src));
                    continue;
@@ -541,7 +544,7 @@ receive_thread(struct Masscan *masscan,

                /* If this is a FIN, handle that. Note that ACK + 
                 * payload + FIN can come together */
                if (TCP_IS_FIN(px, parsed.transport_offset)) {
                if (TCP_IS_FIN(px, parsed.transport_offset) && !TCP_IS_RST(px, parsed.transport_offset)) {
                    tcpcon_handle(tcpcon, tcb, TCP_WHAT_FIN, 
                        0, 0, secs, usecs, seqno_them);
                }
@@ -557,6 +560,7 @@ receive_thread(struct Masscan *masscan,
                 *  This happens when we've sent a FIN, deleted our connection,
                 *  but the other side didn't get the packet.
                 */
                if (!TCP_IS_RST(px, parsed.transport_offset))
                tcpcon_send_FIN(
                    tcpcon,
                    ip_me, ip_them,
@@ -576,7 +580,7 @@ receive_thread(struct Masscan *masscan,

            /* verify: syn-cookies */
            if (syn_hash(ip_them, parsed.port_src) != seqno_me - 1) {
                LOG(1, "%u.%u.%u.%u - bad cookie: ackno=0x%08x expected=0x%08x\n", 
                LOG(2, "%u.%u.%u.%u - bad cookie: ackno=0x%08x expected=0x%08x\n", 
                    (ip_them>>24)&0xff, (ip_them>>16)&0xff, (ip_them>>8)&0xff, (ip_them>>0)&0xff, 
                    seqno_me-1, syn_hash(ip_them, parsed.port_src));
                continue;
+11 −3
Original line number Diff line number Diff line
@@ -236,8 +236,15 @@ tcpcon_destroy_tcb(
            r_entry = &(*r_entry)->next;
    }

    fprintf(stderr, "tcpcon:internal error\n");
    exit(1);
    fprintf(stderr, "tcb: double free: %u.%u.%u.%u : %u (0x%x)\n",
            (tcb->ip_them>>24)&0xFF,
            (tcb->ip_them>>16)&0xFF,
            (tcb->ip_them>> 8)&0xFF,
            (tcb->ip_them>> 0)&0xFF,
            tcb->port_them,
            tcb->seqno_them
            );
    //exit(1);

}

@@ -336,6 +343,7 @@ tcpcon_send_packet(
{
    struct PacketBuffer *response = 0;
    int err = 0;
    uint64_t wait = 100;
    
    
    /* Get a buffer for sending the response packet. This thread doesn't
@@ -347,7 +355,7 @@ tcpcon_send_packet(
            //LOG(0, "packet buffers empty (should be impossible)\n");
            printf("+");
            fflush(stdout);
            pixie_usleep(100); /* no packet available */
            pixie_usleep(wait *= 1.5); /* no packet available */
        }
    }