]> granicus.if.org Git - file/commitdiff
Print the last summary information instead of the first to handle nested
authorChristos Zoulas <christos@zoulas.com>
Fri, 22 Jan 2010 20:56:26 +0000 (20:56 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 22 Jan 2010 20:56:26 +0000 (20:56 +0000)
documents, perhaps we should build a tree and check it that way?

src/cdf.c

index c3f456fb63ac7803a2da7bb253f474a25e17a5a3..d59e52b17b2a4d45c3dcec05b47e08e465eaa0ab 100644 (file)
--- a/src/cdf.c
+++ b/src/cdf.c
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.34 2009/08/12 17:22:22 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.35 2009/09/13 23:25:16 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -676,18 +676,18 @@ cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
        const cdf_directory_t *d;
        static const char name[] = "\05SummaryInformation";
 
-       for (i = 0; i < dir->dir_len; i++)
-               if (dir->dir_tab[i].d_type == CDF_DIR_TYPE_USER_STREAM &&
-                   cdf_namecmp(name, dir->dir_tab[i].d_name, sizeof(name))
+       for (i = dir->dir_len; i > 0; i--)
+               if (dir->dir_tab[i - 1].d_type == CDF_DIR_TYPE_USER_STREAM &&
+                   cdf_namecmp(name, dir->dir_tab[i - 1].d_name, sizeof(name))
                    == 0)
                        break;
 
-       if (i == dir->dir_len) {
+       if (i == 0) {
                DPRINTF(("Cannot find summary information section\n"));
                errno = ESRCH;
                return -1;
        }
-       d = &dir->dir_tab[i];
+       d = &dir->dir_tab[i - 1];
        return cdf_read_sector_chain(info, h, sat, ssat, sst,
            d->d_stream_first_sector, d->d_size, scn);
 }