Avoid memory corruption when things get shot to hell in the image

* plug-ins/common/psd.c: Avoid memory corruption when things
	get shot to hell in the image unpacking phase.
This commit is contained in:
Adam D. Moss 2003-06-16 16:09:59 +00:00
parent 067fb6a390
commit dd29f3e0bb
2 changed files with 22 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2003-06-16 Adam D. Moss <adam@gimp.org>
* plug-ins/common/psd.c: Avoid memory corruption when things
get shot to hell in the image unpacking phase.
2003-06-16 Sven Neumann <sven@gimp.org>
* app/gui/file-open-dialog.c (file_open_dialog_set_type): don't

View File

@ -1,5 +1,5 @@
/*
* PSD Plugin version 2.0.6
* PSD Plugin version 3.0.7
* This GIMP plug-in is designed to load Adobe Photoshop(tm) files (.PSD)
*
* Adam D. Moss <adam@gimp.org> <adam@foxbox.org>
@ -9,7 +9,7 @@
* about the image you tried to load. Please don't send big PSD
* files to me without asking first.
*
* Copyright (C) 1997-2000 Adam D. Moss
* Copyright (C) 1997-2003 Adam D. Moss
* Copyright (C) 1996 Torsten Martinsen
*
* This program is free software; you can redistribute it and/or modify
@ -35,6 +35,11 @@
/*
* Revision history:
*
* 2003.06.16 / v3.0.7 / Adam D. Moss
* Avoid memory corruption when things get shot to hell in the
* image unpacking phase. Major version bumped to distinguish
* GIMP 1.3 development thread.
*
* 2000.08.23 / v2.0.6 / Adam D. Moss
* Eliminate more debugging output (don't people have more
* substantial problems to report? I'm poised at my keyboard).
@ -2263,8 +2268,8 @@ unpack_pb_channel(FILE *fd, guchar *dst, gint32 unpackedlen, guint32 *offset)
while (upremain > 0)
{
(*offset)++;
n = (int) getguchar(fd, "packbits1");
(*offset)++;
if (n >= 128)
n -= 256;
@ -2279,8 +2284,10 @@ unpack_pb_channel(FILE *fd, guchar *dst, gint32 unpackedlen, guint32 *offset)
(*offset)++;
for (; n > 0; --n)
{
*dst = b;
dst ++;
if (upremain >= 0) {
*dst = b;
dst ++;
}
upremain--;
}
}
@ -2288,9 +2295,12 @@ unpack_pb_channel(FILE *fd, guchar *dst, gint32 unpackedlen, guint32 *offset)
{ /* copy next n+1 guchars literally */
for (b = ++n; b > 0; --b)
{
*dst = getguchar(fd, "packbits3");
const guchar c = getguchar(fd, "packbits3");;
if (upremain >= 0) {
*dst = c;
dst ++;
}
(*offset)++;
dst ++;
upremain--;
}
/* upremain -= n;*/