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

UBSAN error in gzread.c #783

Closed
nmoinvaz opened this issue Oct 2, 2020 · 1 comment
Closed

UBSAN error in gzread.c #783

nmoinvaz opened this issue Oct 2, 2020 · 1 comment

Comments

@nmoinvaz
Copy link
Member

nmoinvaz commented Oct 2, 2020

2: /Users/runner/work/zlib-ng/zlib-ng/gzread.c:398:18: runtime error: unsigned integer overflow: 18446744073709551615 * 18446744073709551615 cannot be represented in type 'unsigned long'
2: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/runner/work/zlib-ng/zlib-ng/gzread.c:398:18 in 

https://github.com/nmoinvaz/zlib-ng/runs/1197163500?check_suite_focus=true see macOS Clang run.

@nmoinvaz
Copy link
Member Author

nmoinvaz commented Oct 2, 2020

zlib-ng/gzread.c

Lines 397 to 402 in b55680b

/* compute bytes to read -- error on overflow */
len = nitems * size;
if (size && len / size != nitems) {
gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
return 0;
}

Seems that overflow is expected here.

nmoinvaz added a commit to nmoinvaz/zlib-ng that referenced this issue Oct 31, 2020
gzread.c:398:18: runtime error: unsigned integer overflow: 2 * 18446744073709551615 cannot be represented in type 'unsigned long'
    #0 0x10009d31e in zng_gzfread gzread.c:398
    #1 0x100005b1a in test_gzio example.c:213
    #2 0x10001093b in main example.c:1034
    zlib-ng#3 0x7fff71f57cc8 in start+0x0 (libdyld.dylib:x86_64+0x1acc8)
Dead2 pushed a commit that referenced this issue Nov 2, 2020
gzread.c:398:18: runtime error: unsigned integer overflow: 2 * 18446744073709551615 cannot be represented in type 'unsigned long'
    #0 0x10009d31e in zng_gzfread gzread.c:398
    #1 0x100005b1a in test_gzio example.c:213
    #2 0x10001093b in main example.c:1034
    #3 0x7fff71f57cc8 in start+0x0 (libdyld.dylib:x86_64+0x1acc8)
@nmoinvaz nmoinvaz closed this as completed Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant