jikes, the offset is to be interpreted as offset from the start of the

2007-03-18  Michael Natterer  <mitch@gimp.org>

	* app/file/file-utils.c (file_check_single_magic): jikes, the
	offset is to be interpreted as offset from the start of the file
	for offset >= 0, not offset > 0.


svn path=/trunk/; revision=22140
This commit is contained in:
Michael Natterer 2007-03-18 17:08:08 +00:00 committed by Michael Natterer
parent aec3c1ab3b
commit 6515dc60b4
2 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,12 @@
2007-03-18 Michael Natterer <mitch@gimp.org>
* app/file/file-utils.c (file_check_single_magic): jikes, the
offset is to be interpreted as offset from the start of the file
for offset >= 0, not offset > 0.
2007-03-17 Michael Natterer <mitch@gimp.org>
* app/file/file-utils.c (file_check_single_magic): alow negative
* app/file/file-utils.c (file_check_single_magic): allow negative
offsets in magics and interpret them as relative to the end of the
file.

View File

@ -894,7 +894,7 @@ file_check_single_magic (const gchar *offset,
fileval = buf.st_size;
}
else if (offs > 0 &&
else if (offs >= 0 &&
(offs + numbytes <= headsize)) /* We have it in memory ? */
{
for (k = 0; k < numbytes; k++)
@ -904,7 +904,7 @@ file_check_single_magic (const gchar *offset,
{
gint c = 0;
if (fseek (ifp, offs, (offs > 0) ? SEEK_SET : SEEK_END) < 0)
if (fseek (ifp, offs, (offs >= 0) ? SEEK_SET : SEEK_END) < 0)
return FILE_MATCH_NONE;
for (k = 0; k < numbytes; k++)
@ -938,14 +938,14 @@ file_check_single_magic (const gchar *offset,
if (numbytes <= 0)
return FILE_MATCH_NONE;
if (offs > 0 &&
if (offs >= 0 &&
(offs + numbytes <= headsize)) /* We have it in memory ? */
{
found = (memcmp (mem_testval, file_head + offs, numbytes) == 0);
}
else /* Read it from file */
{
if (fseek (ifp, offs, (offs > 0) ? SEEK_SET : SEEK_END) < 0)
if (fseek (ifp, offs, (offs >= 0) ? SEEK_SET : SEEK_END) < 0)
return FILE_MATCH_NONE;
found = FILE_MATCH_MAGIC;