Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gzip: invalid length and checksum checks #19839

Closed
Casper64 opened this issue Nov 10, 2023 · 0 comments · Fixed by #19849
Closed

gzip: invalid length and checksum checks #19839

Casper64 opened this issue Nov 10, 2023 · 0 comments · Fixed by #19849
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: vlib Bugs/feature requests, that are related to the vlib.

Comments

@Casper64
Copy link
Member

Casper64 commented Nov 10, 2023

Describe the bug

When decompressing a gzipped file of ~5KB the length and checksum verifications fail.

Reproduction Steps

module main

import compress.gzip
import os

fn main() {
	compressed := os.read_bytes('in.xml.gz')!
	println(compressed[0..100])

	decoded := gzip.decompress(compressed)!
	println(decoded.bytestr())
}

Expected Behavior

No errors

Current Behavior

V panic: result not set (length verification failed, got 4548, expected 3289448448)

Possible Solution

The decompression algorithm is correct, because when I remove the length and checksum check I can see that result is correct.

The following code seems to be overflowing/underflowing

(u32(data[data.len - 4]) << 24) | (u32(data[data.len - 3]) << 16) | (u32(data[data.len - 2]) << 8) | data[data.len - 1]

gzip.v

Additional Information/Context

No response

V version

0.4.2

Environment details (OS name and version, etc.)

V full version: V 0.4.2 25777bd.ad935ca
OS: Linux

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@Casper64 Casper64 added the Bug This tag is applied to issues which reports bugs. label Nov 10, 2023
@Casper64 Casper64 self-assigned this Nov 10, 2023
@felipensp felipensp added the Unit: vlib Bugs/feature requests, that are related to the vlib. label Nov 10, 2023
shove70 added a commit to shove70/v that referenced this issue Nov 12, 2023
spytheman pushed a commit that referenced this issue Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: vlib Bugs/feature requests, that are related to the vlib.
Projects
None yet
2 participants