-
Notifications
You must be signed in to change notification settings - Fork 90
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
Heap-buffer-overflow in scale.c:214 #179
Comments
See #154. |
This bug is caused by an integer overflow when calculating the scaled coordinates. The values go negative and it ends up trying to access an out-of-bounds index. It should be fixed by a simple cast like this: diff --git a/src/scale.c b/src/scale.c
index 4767f80..35d87e0 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -204,8 +204,8 @@ scale_without_resampling(
for (h = 0; h < dsth; h++) {
for (w = 0; w < dstw; w++) {
- x = w * srcw / dstw;
- y = h * srch / dsth;
+ x = (long)w * srcw / dstw;
+ y = (long)h * srch / dsth;
for (i = 0; i < depth; i++) {
pos = (y * srcw + x) * depth + i;
dst[(h * dstw + w) * depth + i] = src[pos]; |
So many lonely patches, surely a PR would be better? |
A PR where? It's pointless creating a PR here, since it won't be merged, and the patches are relative to the libsixel/libsixel fork anyway. And I can't create a PR in libsixel/libsixel because that repo is now archived. I'm also not willing to start filing PRs on random forks that may or may not be maintained. But if someone does decide they want to take on the job of maintaining libsixel on an ongoing basis, they're welcome to apply these patches to their fork. If that's too much effort for them, they're likely not serious about being a maintainer anyway. |
FTR, this is a duplicate of libsixel#71. |
Description
Heap-buffer-overflow in scale.c:214 scale_without_resampling() (SEGV)
Case 1
Normal build
with ASan
Case 2
Normal build
with ASan
pocs.zip
Environment
git commit 6a5be8b
Ubuntu 20.04.6 LTS
13th Gen Intel(R) Core(TM) i9-13900
The text was updated successfully, but these errors were encountered: