~ubuntu-branches/ubuntu/utopic/dropbear/utopic-proposed

« back to all changes in this revision

Viewing changes to circbuffer.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Johnston
  • Date: 2005-12-08 19:20:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208192021-nyp9rwnt77nsg6ty
Tags: 0.47-1
* New upstream release.
* SECURITY: Fix incorrect buffer sizing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
 
67
67
unsigned int cbuf_readlen(circbuffer *cbuf) {
68
68
 
69
 
        assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size);
70
 
        assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size);
 
69
        dropbear_assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size);
 
70
        dropbear_assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size);
71
71
 
72
72
        if (cbuf->used == 0) {
73
73
                TRACE(("cbuf_readlen: unused buffer"))
83
83
 
84
84
unsigned int cbuf_writelen(circbuffer *cbuf) {
85
85
 
86
 
        assert(cbuf->used <= cbuf->size);
87
 
        assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size);
88
 
        assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size);
 
86
        dropbear_assert(cbuf->used <= cbuf->size);
 
87
        dropbear_assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size);
 
88
        dropbear_assert(((2*cbuf->size)+cbuf->readpos-cbuf->writepos)%cbuf->size == (cbuf->size-cbuf->used)%cbuf->size);
89
89
 
90
90
        if (cbuf->used == cbuf->size) {
91
91
                TRACE(("cbuf_writelen: full buffer"))
122
122
        }
123
123
 
124
124
        cbuf->used += len;
125
 
        assert(cbuf->used <= cbuf->size);
 
125
        dropbear_assert(cbuf->used <= cbuf->size);
126
126
        cbuf->writepos = (cbuf->writepos + len) % cbuf->size;
127
127
}
128
128
 
132
132
                dropbear_exit("bad cbuf read");
133
133
        }
134
134
 
135
 
        assert(cbuf->used >= len);
 
135
        dropbear_assert(cbuf->used >= len);
136
136
        cbuf->used -= len;
137
137
        cbuf->readpos = (cbuf->readpos + len) % cbuf->size;
138
138
}