Changeset 599 for trunk/server/lib


Ignore:
Timestamp:
Jul 6, 2011, 8:21:13 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.9

Location:
trunk/server/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/lib/tdb/common/io.c

    r456 r599  
    320320{
    321321        struct tdb_record rec;
    322         tdb_off_t offset, new_size;     
     322        tdb_off_t offset, new_size, top_size, map_size;
    323323
    324324        if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
     
    330330        tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1);
    331331
    332         /* always make room for at least 100 more records, and at
    333            least 25% more space. Round the database up to a multiple
    334            of the page size */
    335         new_size = MAX(tdb->map_size + size*100, tdb->map_size * 1.25);
     332        /* limit size in order to avoid using up huge amounts of memory for
     333         * in memory tdbs if an oddball huge record creeps in */
     334        if (size > 100 * 1024) {
     335                top_size = tdb->map_size + size * 2;
     336        } else {
     337                top_size = tdb->map_size + size * 100;
     338        }
     339
     340        /* always make room for at least top_size more records, and at
     341           least 25% more space. if the DB is smaller than 100MiB,
     342           otherwise grow it by 10% only. */
     343        if (tdb->map_size > 100 * 1024 * 1024) {
     344                map_size = tdb->map_size * 1.10;
     345        } else {
     346                map_size = tdb->map_size * 1.25;
     347        }
     348
     349        /* Round the database up to a multiple of the page size */
     350        new_size = MAX(top_size, map_size);
    336351        size = TDB_ALIGN(new_size, tdb->page_size) - tdb->map_size;
    337352
  • trunk/server/lib/util/asn1.c

    r414 r599  
    717717{
    718718        uint8_t b;
     719        bool first_byte = true;
    719720        *i = 0;
    720721
    721722        while (!data->has_error && asn1_tag_remaining(data)>0) {
    722723                if (!asn1_read_uint8(data, &b)) return false;
     724                if (first_byte) {
     725                        if (b & 0x80) {
     726                                /* Number is negative.
     727                                   Set i to -1 for sign extend. */
     728                                *i = -1;
     729                        }
     730                        first_byte = false;
     731                }
    723732                *i = (*i << 8) + b;
    724733        }
Note: See TracChangeset for help on using the changeset viewer.