fix a bunch of bad bounds and off-by-ones, brad@ ok

bump PKGNAME, will submit upstream
This commit is contained in:
avsm 2003-06-20 14:53:12 +00:00
parent 76a6c1c8f4
commit 820a68cf4e
5 changed files with 130 additions and 4 deletions

View File

@ -1,9 +1,11 @@
# $OpenBSD: Makefile,v 1.44 2002/11/21 02:33:59 margarida Exp $
# $OpenBSD: Makefile,v 1.45 2003/06/20 14:53:12 avsm Exp $
# $FreeBSD: Makefile,v 1.45 1999/03/09 01:08:57 nectar Exp $
COMMENT= "image manipulation library for X11"
DISTNAME= imlib-1.9.14
V= 1.9.14
DISTNAME= imlib-${V}
PKGNAME= imlib-${V}p1
CATEGORIES= graphics devel
MASTER_SITES= ${MASTER_SITE_GNOME:=sources/imlib/1.9/}

View File

@ -1,5 +1,5 @@
--- Imlib/load.c.orig Fri Mar 22 09:43:04 2002
+++ Imlib/load.c Thu May 16 22:12:55 2002
--- Imlib/load.c.orig Fri Mar 22 14:43:04 2002
+++ Imlib/load.c Wed Jun 18 15:49:01 2003
@@ -254,7 +254,8 @@ _LoadPNG(ImlibData * id, FILE * f, int *
png_read_image(png_ptr, lines);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@ -38,3 +38,34 @@
return NULL;
}
fread(dbuf, 4, 4, file);
@@ -1061,7 +1064,7 @@ _LoadXPM(ImlibData * id, FILE *file, int
if (line[k] != ' ')
{
s[0] = 0;
- sscanf(&line[k], "%256s", s);
+ sscanf(&line[k], "%255s", s);
slen = strlen(s);
k += slen;
if (!strcmp(s, "c"))
@@ -1861,7 +1864,7 @@ Imlib_load_image(ImlibData * id, char *f
free(im);
return NULL;
}
- sscanf(s, "%256s %i", s1, &num);
+ sscanf(s, "%255s %i", s1, &num);
if (num <= 0)
{
fclose(p);
@@ -1870,10 +1873,10 @@ Imlib_load_image(ImlibData * id, char *f
}
while (fgets(s, 4096, p))
{
- sscanf(s, "%256s", s1);
+ sscanf(s, "%255s", s1);
if (!strcmp("IMAGE", s1))
{
- sscanf(s, "%256s %i %256s %i %i %i %i %i %i %i %i %i", s1, &size,
+ sscanf(s, "%255s %i %255s %i %i %i %i %i %i %i %i %i", s1, &size,
s2, &w, &h, &r, &g, &b, &bl, &br, &bt, &bb);
if (!iden[0])
break;

View File

@ -0,0 +1,69 @@
$OpenBSD: patch-Imlib_utils_c,v 1.1 2003/06/20 14:53:12 avsm Exp $
--- Imlib/utils.c.orig Fri Mar 22 14:43:04 2002
+++ Imlib/utils.c Wed Jun 18 20:59:57 2003
@@ -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);

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-gdk_imlib_io-xpm_c,v 1.1 2003/06/20 14:53:12 avsm Exp $
--- gdk_imlib/io-xpm.c.orig Wed Jun 18 15:47:27 2003
+++ gdk_imlib/io-xpm.c Wed Jun 18 15:47:56 2003
@@ -136,7 +136,7 @@ loader_xpm(FILE *file, int *w, int *h, i
if (line[k] != ' ')
{
s[0] = 0;
- sscanf(&line[k], "%256s", s);
+ sscanf(&line[k], "%255s", s);
slen = strlen(s);
k += slen;
if (!strcmp(s, "c"))

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-gdk_imlib_utils_c,v 1.1 2003/06/20 14:53:12 avsm Exp $
--- gdk_imlib/utils.c.orig Wed Jun 18 15:46:18 2003
+++ gdk_imlib/utils.c Wed Jun 18 15:46:51 2003
@@ -1336,7 +1336,7 @@ gdk_imlib_create_image_from_xpm_data(cha
{
if (line[k] != ' ')
{
- sscanf(&line[k], "%65536s", s);
+ sscanf(&line[k], "%255s", s);
k += strlen(s);
if (!strcmp(s, "c"))
iscolor = 1;