diff options
Diffstat (limited to 'xdelta3/xdelta3.c')
-rwxr-xr-x | xdelta3/xdelta3.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 7bc3b2b..c99ba6f 100755 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -630,15 +630,11 @@ static int xd3_selftest (void); | |||
630 | #if SIZEOF_XOFF_T == 4 | 630 | #if SIZEOF_XOFF_T == 4 |
631 | #define XOFF_T_MAX UINT32_MAX | 631 | #define XOFF_T_MAX UINT32_MAX |
632 | #define xd3_decode_offset xd3_decode_uint32_t | 632 | #define xd3_decode_offset xd3_decode_uint32_t |
633 | //#define xd3_emit_offset xd3_emit_uint32_t | 633 | #define xd3_emit_offset xd3_emit_uint32_t |
634 | //#define xd3_sizeof_offset xd3_sizeof_uint32_t | ||
635 | //#define xd3_read_offset xd3_read_uint32_t | ||
636 | #elif SIZEOF_XOFF_T == 8 | 634 | #elif SIZEOF_XOFF_T == 8 |
637 | #define XOFF_T_MAX UINT64_MAX | 635 | #define XOFF_T_MAX UINT64_MAX |
638 | #define xd3_decode_offset xd3_decode_uint64_t | 636 | #define xd3_decode_offset xd3_decode_uint64_t |
639 | //#define xd3_emit_offset xd3_emit_uint64_t | 637 | #define xd3_emit_offset xd3_emit_uint64_t |
640 | //#define xd3_sizeof_offset xd3_sizeof_uint64_t | ||
641 | //#define xd3_read_offset xd3_read_uint64_t | ||
642 | #endif | 638 | #endif |
643 | 639 | ||
644 | #define USIZE_T_OVERFLOW(a,b) ((USIZE_T_MAX - (usize_t) (a)) < (usize_t) (b)) | 640 | #define USIZE_T_OVERFLOW(a,b) ((USIZE_T_MAX - (usize_t) (a)) < (usize_t) (b)) |
@@ -1855,7 +1851,7 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1855 | if (PART & OFLOW) \ | 1851 | if (PART & OFLOW) \ |
1856 | { \ | 1852 | { \ |
1857 | stream->msg = "overflow in decode_integer"; \ | 1853 | stream->msg = "overflow in decode_integer"; \ |
1858 | return XD3_INTERNAL; \ | 1854 | return XD3_INTERNAL; \ |
1859 | } \ | 1855 | } \ |
1860 | \ | 1856 | \ |
1861 | PART = (PART << 7) | (next & 127); \ | 1857 | PART = (PART << 7) | (next & 127); \ |
@@ -1881,13 +1877,13 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1881 | if (inp == max) \ | 1877 | if (inp == max) \ |
1882 | { \ | 1878 | { \ |
1883 | stream->msg = "end-of-input in read_integer"; \ | 1879 | stream->msg = "end-of-input in read_integer"; \ |
1884 | return XD3_INTERNAL; \ | 1880 | return XD3_INTERNAL; \ |
1885 | } \ | 1881 | } \ |
1886 | \ | 1882 | \ |
1887 | if (val & OFLOW) \ | 1883 | if (val & OFLOW) \ |
1888 | { \ | 1884 | { \ |
1889 | stream->msg = "overflow in read_intger"; \ | 1885 | stream->msg = "overflow in read_intger"; \ |
1890 | return XD3_INTERNAL; \ | 1886 | return XD3_INTERNAL; \ |
1891 | } \ | 1887 | } \ |
1892 | \ | 1888 | \ |
1893 | next = (*inp++); \ | 1889 | next = (*inp++); \ |
@@ -1903,7 +1899,7 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1903 | #define EMIT_INTEGER_TYPE() \ | 1899 | #define EMIT_INTEGER_TYPE() \ |
1904 | /* max 64-bit value in base-7 encoding is 9.1 bytes */ \ | 1900 | /* max 64-bit value in base-7 encoding is 9.1 bytes */ \ |
1905 | uint8_t buf[10]; \ | 1901 | uint8_t buf[10]; \ |
1906 | usize_t bufi = 10; \ | 1902 | usize_t bufi = 10; \ |
1907 | \ | 1903 | \ |
1908 | XD3_ASSERT (num >= 0); \ | 1904 | XD3_ASSERT (num >= 0); \ |
1909 | \ | 1905 | \ |
@@ -1933,16 +1929,17 @@ xd3_sizeof_uint32_t (uint32_t num) | |||
1933 | IF_SIZEOF32(2); | 1929 | IF_SIZEOF32(2); |
1934 | IF_SIZEOF32(3); | 1930 | IF_SIZEOF32(3); |
1935 | IF_SIZEOF32(4); | 1931 | IF_SIZEOF32(4); |
1936 | |||
1937 | return 5; | 1932 | return 5; |
1938 | } | 1933 | } |
1939 | 1934 | ||
1940 | static int | 1935 | static int |
1941 | xd3_decode_uint32_t (xd3_stream *stream, uint32_t *val) | 1936 | xd3_decode_uint32_t (xd3_stream *stream, uint32_t *val) |
1942 | { DECODE_INTEGER_TYPE (stream->dec_32part, UINT32_OFLOW_MASK); } | 1937 | { DECODE_INTEGER_TYPE (stream->dec_32part, UINT32_OFLOW_MASK); } |
1938 | |||
1943 | static int | 1939 | static int |
1944 | xd3_read_uint32_t (xd3_stream *stream, const uint8_t **inpp, const uint8_t *max, uint32_t *valp) | 1940 | xd3_read_uint32_t (xd3_stream *stream, const uint8_t **inpp, const uint8_t *max, uint32_t *valp) |
1945 | { READ_INTEGER_TYPE (uint32_t, UINT32_OFLOW_MASK); } | 1941 | { READ_INTEGER_TYPE (uint32_t, UINT32_OFLOW_MASK); } |
1942 | |||
1946 | #if XD3_ENCODER | 1943 | #if XD3_ENCODER |
1947 | static int | 1944 | static int |
1948 | xd3_emit_uint32_t (xd3_stream *stream, xd3_output **output, uint32_t num) | 1945 | xd3_emit_uint32_t (xd3_stream *stream, xd3_output **output, uint32_t num) |
@@ -1951,17 +1948,18 @@ xd3_emit_uint32_t (xd3_stream *stream, xd3_output **output, uint32_t num) | |||
1951 | #endif | 1948 | #endif |
1952 | 1949 | ||
1953 | #if USE_UINT64 | 1950 | #if USE_UINT64 |
1954 | /* We only ever decode offsets, but the other three are part of the regression test | ||
1955 | * anyway. */ | ||
1956 | static int | 1951 | static int |
1957 | xd3_decode_uint64_t (xd3_stream *stream, uint64_t *val) | 1952 | xd3_decode_uint64_t (xd3_stream *stream, uint64_t *val) |
1958 | { DECODE_INTEGER_TYPE (stream->dec_64part, UINT64_OFLOW_MASK); } | 1953 | { DECODE_INTEGER_TYPE (stream->dec_64part, UINT64_OFLOW_MASK); } |
1959 | #if REGRESSION_TEST | 1954 | |
1960 | #if XD3_ENCODER | 1955 | #if XD3_ENCODER |
1961 | static int | 1956 | static int |
1962 | xd3_emit_uint64_t (xd3_stream *stream, xd3_output **output, uint64_t num) | 1957 | xd3_emit_uint64_t (xd3_stream *stream, xd3_output **output, uint64_t num) |
1963 | { EMIT_INTEGER_TYPE (); } | 1958 | { EMIT_INTEGER_TYPE (); } |
1964 | #endif | 1959 | #endif |
1960 | |||
1961 | /* These are tested but not used */ | ||
1962 | #if REGRESSION_TEST | ||
1965 | static int | 1963 | static int |
1966 | xd3_read_uint64_t (xd3_stream *stream, const uint8_t **inpp, const uint8_t *max, uint64_t *valp) | 1964 | xd3_read_uint64_t (xd3_stream *stream, const uint8_t **inpp, const uint8_t *max, uint64_t *valp) |
1967 | { READ_INTEGER_TYPE (uint64_t, UINT64_OFLOW_MASK); } | 1965 | { READ_INTEGER_TYPE (uint64_t, UINT64_OFLOW_MASK); } |
@@ -1982,6 +1980,7 @@ xd3_sizeof_uint64_t (uint64_t num) | |||
1982 | return 10; | 1980 | return 10; |
1983 | } | 1981 | } |
1984 | #endif | 1982 | #endif |
1983 | |||
1985 | #endif | 1984 | #endif |
1986 | 1985 | ||
1987 | /****************************************************************************************** | 1986 | /****************************************************************************************** |
@@ -3402,7 +3401,7 @@ xd3_emit_hdr (xd3_stream *stream) | |||
3402 | { | 3401 | { |
3403 | /* or (vcd_target) { ... } */ | 3402 | /* or (vcd_target) { ... } */ |
3404 | if ((ret = xd3_emit_size (stream, & HDR_TAIL (stream), stream->src->srclen)) || | 3403 | if ((ret = xd3_emit_size (stream, & HDR_TAIL (stream), stream->src->srclen)) || |
3405 | (ret = xd3_emit_size (stream, & HDR_TAIL (stream), stream->src->srcbase))) { return ret; } | 3404 | (ret = xd3_emit_offset (stream, & HDR_TAIL (stream), stream->src->srcbase))) { return ret; } |
3406 | } | 3405 | } |
3407 | 3406 | ||
3408 | tgt_len = stream->avail_in; | 3407 | tgt_len = stream->avail_in; |