openbsd-ports/graphics/imlib/patches/patch-Imlib_utils_c

79 lines
2.5 KiB
Plaintext

$OpenBSD: patch-Imlib_utils_c,v 1.2 2003/09/01 16:53:00 avsm Exp $
--- Imlib/utils.c.orig 2002-03-22 09:43:04.000000000 -0500
+++ Imlib/utils.c 2003-08-28 13:19:43.000000000 -0400
@@ -801,6 +801,7 @@ Imlib_crop_and_clone_image(ImlibData * i
unsigned char *ptr1, *ptr2;
ImlibImage *im2;
char *s;
+ size_t s_size;
if (!im)
return NULL;
@@ -872,10 +873,11 @@ Imlib_crop_and_clone_image(ImlibData * i
im2->rgb_width = w;
im2->rgb_height = h;
im2->alpha_data = NULL;
- s = malloc(strlen(im->filename) + 320);
+ s_size = strlen(im->filename + 320);
+ s = malloc(s_size);
if (s)
{
- snprintf(s, sizeof(s), "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
+ snprintf(s, s_size, "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
im2->filename = malloc(strlen(s) + 1);
if (im2->filename)
strcpy(im2->filename, s);
@@ -1211,6 +1213,7 @@ Imlib_clone_image(ImlibData * id, ImlibI
{
ImlibImage *im2;
char *s;
+ size_t s_size;
if (!im)
return NULL;
@@ -1239,10 +1242,11 @@ Imlib_clone_image(ImlibData * id, ImlibI
}
else
im2->alpha_data = NULL;
- s = malloc(strlen(im->filename) + 320);
+ s_size = strlen(im->filename) + 320;
+ s = malloc(s_size);
if (s)
{
- snprintf(s, sizeof(s), "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
+ snprintf(s, s_size, "%s_%x_%x", im->filename, (int)time(NULL), (int)rand());
im2->filename = malloc(strlen(s) + 1);
if (im2->filename)
strcpy(im2->filename, s);
@@ -1285,6 +1289,7 @@ Imlib_clone_scaled_image(ImlibData * id,
{
ImlibImage *im2;
char *s;
+ size_t s_size;
if ((!im) || (w <= 0) || (h <= 0))
return NULL;
@@ -1417,10 +1422,11 @@ Imlib_clone_scaled_image(ImlibData * id,
}
else
im2->alpha_data = NULL;
- s = malloc(strlen(im->filename) + 320);
+ s_size = strlen(im->filename) + 320;
+ s = malloc(s_size);
if (s)
{
- snprintf(s, sizeof(s), "%s_%x_%x_%x_%x", im->filename, (int)time(NULL), w, h, (int)rand());
+ snprintf(s, s_size, "%s_%x_%x_%x_%x", im->filename, (int)time(NULL), w, h, (int)rand());
im2->filename = malloc(strlen(s) + 1);
if (im2->filename)
strcpy(im2->filename, s);
@@ -1596,7 +1602,7 @@ Imlib_create_image_from_xpm_data(ImlibDa
{
if (line[k] != ' ')
{
- sscanf(&line[k], "%65536s", s);
+ sscanf(&line[k], "%255s", s);
k += strlen(s);
if (!strcmp(s, "c"))
iscolor = 1;