mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
prevent signed int overflow in left shift ops
force unsigned when shifting by 24. Change-Id: Ie229d252e2e4078107cd705b09397e686a321ffd
This commit is contained in:
parent
7ebdf110af
commit
f4f90880a8
@ -109,15 +109,15 @@ typedef enum {
|
||||
|
||||
static InputFileFormat GetImageType(FILE* in_file) {
|
||||
InputFileFormat format = UNSUPPORTED;
|
||||
unsigned int magic;
|
||||
unsigned char buf[4];
|
||||
uint32_t magic;
|
||||
uint8_t buf[4];
|
||||
|
||||
if ((fread(&buf[0], 4, 1, in_file) != 1) ||
|
||||
(fseek(in_file, 0, SEEK_SET) != 0)) {
|
||||
return format;
|
||||
}
|
||||
|
||||
magic = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
||||
magic = ((uint32_t)buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
||||
if (magic == 0x89504E47U) {
|
||||
format = PNG_;
|
||||
} else if (magic >= 0xFFD8FF00U && magic <= 0xFFD8FFFFU) {
|
||||
|
@ -710,7 +710,7 @@ static int Import(WebPPicture* const picture,
|
||||
for (y = 0; y < height; ++y) {
|
||||
for (x = 0; x < width; ++x) {
|
||||
const int offset = step * x + y * rgb_stride;
|
||||
const uint32_t argb = (a_ptr[offset] << 24) |
|
||||
const uint32_t argb = ((uint32_t)a_ptr[offset] << 24) |
|
||||
(r_ptr[offset] << 16) |
|
||||
(g_ptr[offset] << 8) |
|
||||
(b_ptr[offset]);
|
||||
@ -810,7 +810,7 @@ int WebPPictureYUVAToARGB(WebPPicture* picture) {
|
||||
const uint8_t* const src = picture->a + y * picture->a_stride;
|
||||
int x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | (src[x] << 24);
|
||||
argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | ((uint32_t)src[x] << 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user