Read checksum bytes even if ignoring its value

This commit is contained in:
Nigel Tao committed 2018-03-28 11:21:03 +11:00
1 parent 72449fa0ec
commit 153d1276a1
6 files changed
+24 -6

No files matched your search

+9 -1
View File
@@ -520,6 +520,7 @@ typedef struct {
uint16_t v_xlen;
uint32_t v_checksum_got;
wuffs_gzip__status v_z;
uint32_t v_checksum_want;
uint64_t scratch;
} c_decode[1];
} private_impl;
@@ -1024,6 +1025,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
uint16_t v_xlen;
uint32_t v_checksum_got;
wuffs_gzip__status v_z;
uint32_t v_checksum_want;
uint8_t* b_wptr_dst = NULL;
uint8_t* b_wstart_dst = NULL;
@@ -1066,6 +1068,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
v_xlen = self->private_impl.c_decode[0].v_xlen;
v_checksum_got = self->private_impl.c_decode[0].v_checksum_got;
v_z = self->private_impl.c_decode[0].v_z;
v_checksum_want = self->private_impl.c_decode[0].v_checksum_want;
} else {
}
switch (coro_susp_point) {
@@ -1246,6 +1249,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(16);
}
label_2_break:;
{
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(17);
uint32_t t_10;
if (WUFFS_BASE__LIKELY(b_rend_src - b_rptr_src >= 4)) {
@@ -1271,7 +1275,10 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
self->private_impl.c_decode[0].scratch |= ((uint64_t)(t_9));
}
}
if (!self->private_impl.f_ignore_checksum && (v_checksum_got != t_10)) {
v_checksum_want = t_10;
}
if (!self->private_impl.f_ignore_checksum &&
(v_checksum_got != v_checksum_want)) {
}
goto ok;
@@ -1288,6 +1295,7 @@ suspend:
self->private_impl.c_decode[0].v_xlen = v_xlen;
self->private_impl.c_decode[0].v_checksum_got = v_checksum_got;
self->private_impl.c_decode[0].v_z = v_z;
self->private_impl.c_decode[0].v_checksum_want = v_checksum_want;
goto exit;
exit:
+9 -1
View File
@@ -448,6 +448,7 @@ typedef struct {
uint16_t v_x;
uint32_t v_checksum_got;
wuffs_zlib__status v_z;
uint32_t v_checksum_want;
uint64_t scratch;
} c_decode[1];
} private_impl;
@@ -973,6 +974,7 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
uint16_t v_x;
uint32_t v_checksum_got;
wuffs_zlib__status v_z;
uint32_t v_checksum_want;
uint8_t* b_wptr_dst = NULL;
uint8_t* b_wstart_dst = NULL;
@@ -1013,6 +1015,7 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
v_x = self->private_impl.c_decode[0].v_x;
v_checksum_got = self->private_impl.c_decode[0].v_checksum_got;
v_z = self->private_impl.c_decode[0].v_z;
v_checksum_want = self->private_impl.c_decode[0].v_checksum_want;
} else {
}
switch (coro_susp_point) {
@@ -1114,6 +1117,7 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
}
label_0_break:;
{
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
uint32_t t_4;
if (WUFFS_BASE__LIKELY(b_rend_src - b_rptr_src >= 4)) {
@@ -1139,7 +1143,10 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
self->private_impl.c_decode[0].scratch |= ((uint64_t)(t_3));
}
}
if (!self->private_impl.f_ignore_checksum && (v_checksum_got != t_4)) {
v_checksum_want = t_4;
}
if (!self->private_impl.f_ignore_checksum &&
(v_checksum_got != v_checksum_want)) {
status = WUFFS_ZLIB__ERROR_CHECKSUM_MISMATCH;
goto exit;
}
@@ -1156,6 +1163,7 @@ suspend:
self->private_impl.c_decode[0].v_x = v_x;
self->private_impl.c_decode[0].v_checksum_got = v_checksum_got;
self->private_impl.c_decode[0].v_z = v_z;
self->private_impl.c_decode[0].v_checksum_want = v_checksum_want;
goto exit;
exit:
+1
View File
@@ -520,6 +520,7 @@ typedef struct {
uint16_t v_xlen;
uint32_t v_checksum_got;
wuffs_gzip__status v_z;
uint32_t v_checksum_want;
uint64_t scratch;
} c_decode[1];
} private_impl;
+1
View File
@@ -448,6 +448,7 @@ typedef struct {
uint16_t v_x;
uint32_t v_checksum_got;
wuffs_zlib__status v_z;
uint32_t v_checksum_want;
uint64_t scratch;
} c_decode[1];
} private_impl;
+2 -2
View File
@@ -101,8 +101,8 @@ pub func decoder.decode?(dst writer1, src reader1)() {
}
yield z
}
// TODO: read the 4 bytes regardless of this.ignore_checksum.
if (not this.ignore_checksum) and (checksum_got != in.src.read_u32be?()) {
var checksum_want u32 = in.src.read_u32be?()
if (not this.ignore_checksum) and (checksum_got != checksum_want) {
// TODO: return error "checksum mismatch"
}
// TODO: handle the 4 byte ISIZE field.
+2 -2
View File
@@ -61,8 +61,8 @@ pub func decoder.decode?(dst writer1, src reader1)() {
}
yield z
}
// TODO: read the 4 bytes regardless of this.ignore_checksum.
if (not this.ignore_checksum) and (checksum_got != in.src.read_u32be?()) {
var checksum_want u32 = in.src.read_u32be?()
if (not this.ignore_checksum) and (checksum_got != checksum_want) {
return error "checksum mismatch"
}
}