Package: sxiv
Version: 1.3.1-1
Severity: minor
Tags: patch
The following patch fixes two bugs in sxiv found using gcc's
-fsanitize=undefined/addess options:
Firstly, the value of (0xff << 24) is undefined on 32-bit systems, as
it involves shifting a one into the sign bit (0xff is a signed int
literal).
Secondly, it seems that the 'marked' field of the elements in the
files[] array is never initialised properly before use (the
instrumented sxiv binary complains about a load of an invalid _Bool
value).
--- a/image.c
+++ b/image.c
@@ -245,7 +245,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
r =
cmap->Colors[rows[i-y][j-x]].Red;
g =
cmap->Colors[rows[i-y][j-x]].Green;
b =
cmap->Colors[rows[i-y][j-x]].Blue;
- *ptr = 0xff << 24 | r << 16 | g
<< 8 | b;
+ *ptr = 0xffU << 24 | r << 16 |
g << 8 | b;
}
ptr++;
}
--- a/main.c
+++ b/main.c
@@ -157,6 +157,7 @@ void check_add_file(char *filename, bool given)
files[fileidx].base = ++bn;
else
files[fileidx].base = files[fileidx].name;
+ files[fileidx].marked = false;
fileidx++;
}
--