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

« back to all changes in this revision

Viewing changes to keyimport.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:
173
173
                buf_incrpos(buf, len);
174
174
        } while (len > 0 && buf->len != buf->pos);
175
175
 
 
176
        fclose(fp);
 
177
 
176
178
        if (buf->pos != buf->len) {
177
179
                ret = 0;
178
180
        } else {
203
205
        unsigned long outlen;
204
206
        int rawcpl;
205
207
        rawcpl = cpl * 3 / 4;
206
 
        assert((unsigned int)cpl < sizeof(out));
 
208
        dropbear_assert((unsigned int)cpl < sizeof(out));
207
209
 
208
210
    while (datalen > 0) {
209
211
                n = (datalen < rawcpl ? datalen : rawcpl);
714
716
        }
715
717
#endif
716
718
 
717
 
        assert(keytype != -1);
 
719
        dropbear_assert(keytype != -1);
718
720
 
719
721
        /*
720
722
         * Fetch the key blobs.
913
915
         * with the same value. Those are all removed and the rest is
914
916
         * returned.
915
917
         */
916
 
        assert(pos == len);
 
918
        dropbear_assert(pos == len);
917
919
        while (pos < outlen) {
918
920
                outblob[pos++] = outlen - len;
919
921
        }
1491
1493
                privlen = pos - publen;
1492
1494
        }
1493
1495
 
1494
 
        assert(privlen > 0);                       /* should have bombed by now if not */
 
1496
        dropbear_assert(privlen > 0);                      /* should have bombed by now if not */
1495
1497
 
1496
1498
        retkey = snew(struct ssh2_userkey);
1497
1499
        retkey->alg = alg;
1557
1559
                pos += ssh2_read_mpint(privblob+pos, privlen-pos, &q);
1558
1560
                pos += ssh2_read_mpint(privblob+pos, privlen-pos, &iqmp);
1559
1561
 
1560
 
                assert(e.start && iqmp.start); /* can't go wrong */
 
1562
                dropbear_assert(e.start && iqmp.start); /* can't go wrong */
1561
1563
 
1562
1564
                numbers[0] = e;
1563
1565
                numbers[1] = d;
1581
1583
                pos = 0;
1582
1584
                pos += ssh2_read_mpint(privblob+pos, privlen-pos, &x);
1583
1585
 
1584
 
                assert(y.start && x.start); /* can't go wrong */
 
1586
                dropbear_assert(y.start && x.start); /* can't go wrong */
1585
1587
 
1586
1588
                numbers[0] = p;
1587
1589
                numbers[1] = g;
1593
1595
                initial_zero = 1;
1594
1596
                type = "dl-modp{sign{dsa-nist-sha1},dh{plain}}";
1595
1597
        } else {
1596
 
                assert(0);                                       /* zoinks! */
 
1598
                dropbear_assert(0);                                      /* zoinks! */
1597
1599
        }
1598
1600
 
1599
1601
        /*
1637
1639
        }
1638
1640
        ciphertext = (char *)outblob+lenpos+4;
1639
1641
        cipherlen = pos - (lenpos+4);
1640
 
        assert(!passphrase || cipherlen % 8 == 0);
 
1642
        dropbear_assert(!passphrase || cipherlen % 8 == 0);
1641
1643
        /* Wrap up the encrypted blob string. */
1642
1644
        PUT_32BIT(outblob+lenpos, cipherlen);
1643
1645
        /* And finally fill in the total length field. */
1644
1646
        PUT_32BIT(outblob+4, pos);
1645
1647
 
1646
 
        assert(pos < outlen);
 
1648
        dropbear_assert(pos < outlen);
1647
1649
 
1648
1650
        /*
1649
1651
         * Encrypt the key.