Commit de3613e7 authored by robertdavidgraham's avatar robertdavidgraham
Browse files

tcb leakage

parent 3781e798
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -45,14 +45,14 @@ timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry,
{
    unsigned index;

    /* Unlink from wherever the entry came from */
    timeout_unlink(entry);

    /* Initialize the new entry */    
    entry->timestamp = timestamp;
    entry->offset = (unsigned)offset;

    
    /* Unlink from whereas the entry came from */
    timeout_unlink(entry);
    
    
    /* Link it into it's new location */
    index = timestamp & timeouts->mask;
+5 −2
Original line number Diff line number Diff line
@@ -3,9 +3,11 @@
#include <stdint.h>
#include <stdio.h>
#include <stddef.h> /* offsetof*/

#if defined(_MSC_VER)
#undef inline
#define inline _inline
#endif
struct Timeouts;
struct TimeoutEntry;

/***************************************************************************
 ***************************************************************************/
@@ -29,6 +31,7 @@ timeout_unlink(struct TimeoutEntry *entry)
        entry->next->prev = entry->prev;
    entry->next = 0;
    entry->prev = 0;
    entry->timestamp = 0;
}

static inline void
+5 −5
Original line number Diff line number Diff line
@@ -63,16 +63,16 @@ packet_trace(FILE *fp, const unsigned char *px, size_t length, unsigned is_sent)
                case 1:strcpy_s(sz_type, sizeof(sz_type), "response"); break;
                default: sprintf_s(sz_type, sizeof(sz_type), "unknown(%u)", type); break;
            }
            fprintf(stderr, "%s (%5.4f) ARP  %-21s > %-21s %s\n", direction,
            fprintf(fp, "%s (%5.4f) ARP  %-21s > %-21s %s\n", direction,
                    timestamp - global_timestamp_start, from, to, sz_type);
            break;
        case FOUND_DNS:
        case FOUND_UDP:
            fprintf(stderr, "%s (%5.4f) UDP  %-21s > %-21s \n", direction,
            fprintf(fp, "%s (%5.4f) UDP  %-21s > %-21s \n", direction,
                    timestamp - global_timestamp_start, from, to);
            break;
        case FOUND_ICMP:
            fprintf(stderr, "%s (%5.4f) ICMP %-21s > %-21s \n", direction,
            fprintf(fp, "%s (%5.4f) ICMP %-21s > %-21s \n", direction,
                    timestamp - global_timestamp_start, from, to);
            break;
        case FOUND_TCP:
@@ -103,13 +103,13 @@ packet_trace(FILE *fp, const unsigned char *px, size_t length, unsigned is_sent)
                              );
                    break;
            }
            fprintf(stderr, "%s (%5.4f) TCP  %-21s > %-21s %s\n", direction,
            fprintf(fp, "%s (%5.4f) TCP  %-21s > %-21s %s\n", direction,
                    timestamp - global_timestamp_start, from, to, sz_type);
            break;
        case FOUND_IPV6:
            break;
        default:
            fprintf(stderr, "%s (%5.4f) UNK  %-21s > %-21s [%u]\n", direction, 
            fprintf(fp, "%s (%5.4f) UNK  %-21s > %-21s [%u]\n", direction, 
                    timestamp - global_timestamp_start, from, to, parsed.found);
            break;
    }
+31 −24
Original line number Diff line number Diff line
@@ -107,6 +107,11 @@ tcpcon_timeouts(struct TCP_ConnectionTable *tcpcon, unsigned secs, unsigned usec
            secs, usecs,
            0);

        /* If the TCB hasn't been destroyed, then we need to make sure
         * there is a timeout associated with it */
        if (tcb->timeout->prev == 0 && tcb->ip_them != 0 && tcb->port_them != 0) {
            timeouts_add(tcpcon->timeouts, tcb->timeout, offsetof(struct TCP_Control_Block, timeout), TICKS_FROM_TV(secs+2, usecs));
        }
    }
}

@@ -212,6 +217,11 @@ tcpcon_destroy_tcb(
            }
            timeout_unlink(tcb->timeout);
            
            tcb->ip_them = 0;
            tcb->port_them = 0;
            tcb->ip_me = 0;
            tcb->port_me = 0;

            (*r_entry) = tcb->next;
            tcb->next = tcpcon->freed_list;
            tcpcon->freed_list = tcb;
@@ -602,12 +612,7 @@ tcpcon_handle(struct TCP_ConnectionTable *tcpcon, struct TCP_Control_Block *tcb,
            default:
                x = 0;
            }
            if (!x) {
                break;
            }



            if (x) {
                /* send request */
                x_len = strlen((const char*)x);
                tcpcon_send_packet(tcpcon, tcb,
@@ -623,9 +628,11 @@ tcpcon_handle(struct TCP_ConnectionTable *tcpcon, struct TCP_Control_Block *tcb,
                /* change our state to reflect that we are now waiting for 
                 * acknowledgement of the data we've sent */
                tcb->tcpstate = STATE_PAYLOAD_SENT;
            }

            /* Add a timeout so that we can resend the data in case it
             * goes missing */
             * goes missing. Note that we put this back in the timeout
             * system regardless if we've sent data. */
            timeouts_add(   tcpcon->timeouts, 
                            tcb->timeout,
                            offsetof(struct TCP_Control_Block, timeout),
+0 −1
Original line number Diff line number Diff line
@@ -194,7 +194,6 @@ xring_selftest()
        struct Test test[1];

        result = run_test(test);
        printf(".");
        if (result != 500500) {
            printf("xring: selftest failed with %llu\n", result);
            return 1;
Loading