Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/lib/compression
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/lib/compression/lzxpress.c

    r414 r740  
    3535#include "replace.h"
    3636#include "lzxpress.h"
     37#include "../lib/util/byteorder.h"
    3738
    3839
     
    8182        uncompressed_pos = 0;
    8283        indic = 0;
     84        *(uint32_t *)compressed = 0;
    8385        compressed_pos = sizeof(uint32_t);
    8486        indic_pos = &compressed[0];
     
    130132                                /* Classical meta-data */
    131133                                metadata = (uint16_t)(((best_offset - 1) << 3) | (best_len - 3));
    132                                 dest[metadata_size / sizeof(uint16_t)] = metadata;
     134                                SSVAL(dest, metadata_size / sizeof(uint16_t), metadata);
    133135                                metadata_size += sizeof(uint16_t);
    134136                        } else {
    135137                                metadata = (uint16_t)(((best_offset - 1) << 3) | 7);
    136                                 dest[metadata_size / sizeof(uint16_t)] = metadata;
     138                                SSVAL(dest, metadata_size / sizeof(uint16_t), metadata);
    137139                                metadata_size = sizeof(uint16_t);
    138140
     
    156158                                        }
    157159
    158                                         /* Additionnal best_len */
     160                                        /* Additional best_len */
    159161                                        compressed[compressed_pos + metadata_size] = (best_len - (3 + 7 + 15)) & 0xFF;
    160162                                        metadata_size += sizeof(uint8_t);
     
    168170                                        }
    169171
    170                                         /* Additionnal best_len */
     172                                        /* Additional best_len */
    171173                                        compressed[compressed_pos + metadata_size] = 255;
    172174
     
    199201
    200202                if ((indic_bit - 1) % 32 > (indic_bit % 32)) {
    201                         *(uint32_t *)indic_pos = indic;
     203                        SIVAL(indic_pos, 0, indic);
    202204                        indic = 0;
    203205                        indic_pos = &compressed[compressed_pos];
     
    213215                compressed_pos++;
    214216                if (((indic_bit - 1) % 32) > (indic_bit % 32)){
    215                         *(uint32_t *)indic_pos = indic;
     217                        SIVAL(indic_pos, 0, indic);
    216218                        indic = 0;
    217219                        indic_pos = &compressed[compressed_pos];
     
    224226                        indic |= 0 << (32 - ((indic_bit % 32) + 1));
    225227
    226                 *(uint32_t *)indic_pos = indic;
     228                *(uint32_t *)&compressed[compressed_pos] = 0;
     229                SIVAL(indic_pos, 0, indic);
    227230                compressed_pos += sizeof(uint32_t);
    228231        }
  • vendor/current/lib/compression/testsuite.c

    r414 r740  
    2121#include "includes.h"
    2222#include "torture/torture.h"
    23 #include "../compression/mszip.h"
     23#include "talloc.h"
     24#include "mszip.h"
     25#include "lzxpress.h"
     26
     27/*
     28  test lzxpress
     29 */
     30static bool test_lzxpress(struct torture_context *test)
     31{
     32        TALLOC_CTX *tmp_ctx = talloc_new(test);
     33        uint8_t *data;
     34        const char *fixed_data = "this is a test. and this is a test too";
     35        const uint8_t fixed_out[] = { 0x00, 0x20, 0x00, 0x04, 0x74, 0x68, 0x69, 0x73,
     36                                      0x20, 0x10, 0x00, 0x61, 0x20, 0x74, 0x65, 0x73,
     37                                      0x74, 0x2E, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x9F,
     38                                      0x00, 0x04, 0x20, 0x74, 0x6F, 0x6F, 0x00, 0x00,
     39                                      0x00, 0x00 };
     40        ssize_t c_size;
     41        uint8_t *out, *out2;
     42
     43        data = talloc_size(tmp_ctx, 1023);
     44        out  = talloc_size(tmp_ctx, 2048);
     45        memset(out, 0x42, talloc_get_size(out));
     46
     47        torture_comment(test, "lzxpress fixed compression\n");
     48        c_size = lzxpress_compress((const uint8_t *)fixed_data,
     49                                   strlen(fixed_data),
     50                                   out,
     51                                   talloc_get_size(out));
     52
     53        torture_assert_int_equal(test, c_size, sizeof(fixed_out), "fixed lzxpress_compress size");
     54        torture_assert_mem_equal(test, out, fixed_out, c_size, "fixed lzxpress_compress data");
     55
     56        torture_comment(test, "lzxpress fixed decompression\n");
     57        out2  = talloc_size(tmp_ctx, strlen(fixed_data));
     58        c_size = lzxpress_decompress(out,
     59                                     sizeof(fixed_out),
     60                                     out2,
     61                                     talloc_get_size(out2));
     62
     63        torture_assert_int_equal(test, c_size, strlen(fixed_data), "fixed lzxpress_decompress size");
     64        torture_assert_mem_equal(test, out2, fixed_data, c_size, "fixed lzxpress_decompress data");
     65
     66        return true;
     67}
     68
    2469
    2570struct torture_suite *torture_local_compression(TALLOC_CTX *mem_ctx)
    2671{
    27         struct torture_suite *suite = torture_suite_create(mem_ctx, "COMPRESSION");
     72        struct torture_suite *suite = torture_suite_create(mem_ctx, "compression");
     73
     74        torture_suite_add_simple_test(suite, "lzxpress", test_lzxpress);
    2875
    2976        return suite;
Note: See TracChangeset for help on using the changeset viewer.