mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
Add unknown cell queue entry type case to channel/queue_impossible unit test
This commit is contained in:
parent
f7951d318a
commit
b5d4ef18e1
@ -896,6 +896,32 @@ test_channel_queue_impossible(void *arg)
|
||||
test_assert(test_cells_written == old_count);
|
||||
test_eq(chan_cell_queue_len(&(ch->outgoing_queue)), 0);
|
||||
|
||||
/* Unknown cell type case */
|
||||
test_chan_accept_cells = 0;
|
||||
ch->state = CHANNEL_STATE_MAINT;
|
||||
cell = tor_malloc_zero(sizeof(cell_t));
|
||||
make_fake_cell(cell);
|
||||
channel_write_cell(ch, cell);
|
||||
|
||||
/* Check that it's queued */
|
||||
test_eq(chan_cell_queue_len(&(ch->outgoing_queue)),1);
|
||||
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
|
||||
test_assert(q);
|
||||
if (q) {
|
||||
test_eq(q->type, CELL_QUEUE_FIXED);
|
||||
test_eq(q->u.fixed.cell, cell);
|
||||
}
|
||||
/* Clobber it, including the queue entry type */
|
||||
tor_free(q->u.fixed.cell);
|
||||
q->u.fixed.cell = NULL;
|
||||
q->type = CELL_QUEUE_PACKED + 1;
|
||||
|
||||
/* Let it drain and check that the bad entry is discarded */
|
||||
test_chan_accept_cells = 1;
|
||||
channel_change_state(ch, CHANNEL_STATE_OPEN);
|
||||
test_assert(test_cells_written == old_count);
|
||||
test_eq(chan_cell_queue_len(&(ch->outgoing_queue)), 0);
|
||||
|
||||
done:
|
||||
tor_free(ch);
|
||||
free_cell_pool();
|
||||
|
Loading…
Reference in New Issue
Block a user