summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2014-10-28 10:03:11 +0100
committerSebastian Dransfeld <sd@tango.flipp.net>2014-10-31 12:59:51 +0100
commit17d6bed1b84dd0540f7693184110406c220233ae (patch)
tree17b055a442894bbd79bdbf7b0ba14de8bbdae1c7
parent53a5cbb47608adcdf574960b26eec8c3039df244 (diff)
downloadevas_generic_loaders-17d6bed1b84dd0540f7693184110406c220233ae.tar.gz
raw: Make sure to keep the correct sign
unsigned short * unsigned short = int, so for large image sizes the calculation will be wrong. Fixes CID 63746 and CID 63747 @fix
-rw-r--r--src/bin/common/shmfile.c2
-rw-r--r--src/bin/common/shmfile.h2
-rw-r--r--src/bin/raw/main.c10
3 files changed, 7 insertions, 7 deletions
diff --git a/src/bin/common/shmfile.c b/src/bin/common/shmfile.c
index 725c67b..7a51edd 100644
--- a/src/bin/common/shmfile.c
+++ b/src/bin/common/shmfile.c
@@ -25,7 +25,7 @@ void *shm_addr = NULL;
char *shmfile = NULL;
void
-shm_alloc(int dsize)
+shm_alloc(unsigned long dsize)
{
#ifdef HAVE_SHM_OPEN
if (!shmfile) shmfile = malloc(1024);
diff --git a/src/bin/common/shmfile.h b/src/bin/common/shmfile.h
index b41c9cb..f70a8fd 100644
--- a/src/bin/common/shmfile.h
+++ b/src/bin/common/shmfile.h
@@ -10,7 +10,7 @@ extern int shm_size;
extern void *shm_addr;
extern char *shmfile;
-void shm_alloc (int dsize);
+void shm_alloc (unsigned long dsize);
void shm_free (void);
#ifdef __cplusplus
diff --git a/src/bin/raw/main.c b/src/bin/raw/main.c
index 98476f3..2e36119 100644
--- a/src/bin/raw/main.c
+++ b/src/bin/raw/main.c
@@ -37,7 +37,7 @@
#endif
static int fd = -1;
-static int seg_size = 0;
+static size_t seg_size = 0;
static unsigned char *seg = MAP_FAILED;
static libraw_data_t *raw_data = NULL;
static void *data = NULL;
@@ -146,14 +146,14 @@ read_raw_data()
for (count = 0; count < image->data_size; count +=2)
SWAP(image->data[count], image->data[count + 1]);
#undef SWAP
- shm_alloc(image->width * image->height * (sizeof(DATA32)));
+ shm_alloc((unsigned int)(image->width * image->height) * (sizeof(DATA32)));
if (!shm_addr)
goto clean_image;
data = shm_addr;
- memset(shm_addr, 0, image->width * image->height * (sizeof(DATA32)));
+ memset(shm_addr, 0, (unsigned int)(image->width * image->height) * (sizeof(DATA32)));
dataptr = data;
bufptr = image->data;
- for (count = image->width * image->height; count > 0; --count)
+ for (count = (unsigned int)(image->width * image->height); count > 0; --count)
{
*dataptr = ARGB_JOIN(0xff, bufptr[0], bufptr[1], bufptr[2]);
dataptr++;
@@ -229,7 +229,7 @@ int main(int argc, char **argv)
else
{
printf("data\n");
- fwrite(data, width * height * sizeof(DATA32), 1, stdout);
+ fwrite(data, (unsigned int)(width * height) * sizeof(DATA32), 1, stdout);
}
shm_free();
}