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

« back to all changes in this revision

Viewing changes to buffer.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:
153
153
unsigned char buf_getbyte(buffer* buf) {
154
154
 
155
155
        /* This check is really just ==, but the >= allows us to check for the
156
 
         * assert()able case of pos > len, which should _never_ happen. */
 
156
         * bad case of pos > len, which should _never_ happen. */
157
157
        if (buf->pos >= buf->len) {
158
158
                dropbear_exit("bad buf_getbyte");
159
159
        }
160
160
        return buf->data[buf->pos++];
161
161
}
162
162
 
 
163
/* Get a bool from the buffer and increment the pos */
 
164
unsigned char buf_getbool(buffer* buf) {
 
165
 
 
166
        unsigned char b;
 
167
        b = buf_getbyte(buf);
 
168
        if (b != 0)
 
169
                b = 1;
 
170
        return b;
 
171
}
 
172
 
163
173
/* put a byte, incrementing the length if required */
164
174
void buf_putbyte(buffer* buf, unsigned char val) {
165
175
 
260
270
        unsigned int len, pad = 0;
261
271
        TRACE(("enter buf_putmpint"))
262
272
 
263
 
        assert(mp != NULL);
 
273
        dropbear_assert(mp != NULL);
264
274
 
265
275
        if (SIGN(mp) == MP_NEG) {
266
276
                dropbear_exit("negative bignum");