From: Christos Zoulas Date: Mon, 20 Jun 2016 16:08:14 +0000 (+0000) Subject: PR/559: It is not an error if the short stream is missing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14720391137a63f0e5415d63e63bae0a057a4f1f;p=file PR/559: It is not an error if the short stream is missing. --- diff --git a/src/cdf.c b/src/cdf.c index 4ec65b45..0a8aa8f2 100644 --- a/src/cdf.c +++ b/src/cdf.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf.c,v 1.82 2016/06/01 22:25:25 christos Exp $") +FILE_RCSID("@(#)$File: cdf.c,v 1.83 2016/06/20 16:08:14 christos Exp $") #endif #include @@ -731,22 +731,25 @@ cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h, break; /* If the it is not there, just fake it; some docs don't have it */ - if (i == dir->dir_len) + if (i == dir->dir_len) { + DPRINTF(("Cannot find root storage dir\n")); goto out; + } d = &dir->dir_tab[i]; *root = d; /* If the it is not there, just fake it; some docs don't have it */ - if (d->d_stream_first_sector < 0) + if (d->d_stream_first_sector < 0) { + DPRINTF(("No first secror in dir\n")); goto out; + } return cdf_read_long_sector_chain(info, h, sat, d->d_stream_first_sector, d->d_size, scn); out: scn->sst_tab = NULL; (void)cdf_zero_stream(scn); - errno = EFTYPE; - return -1; + return 0; } static int @@ -1275,7 +1278,7 @@ cdf_dump(const void *v, size_t len) } void -cdf_dump_stream(const cdf_header_t *h, const cdf_stream_t *sst) +cdf_dump_stream(const cdf_stream_t *sst) { size_t ss = sst->sst_ss; cdf_dump(sst->sst_tab, ss * sst->sst_len); @@ -1331,7 +1334,7 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h, name, d->d_stream_first_sector, d->d_size); break; } - cdf_dump_stream(h, &scn); + cdf_dump_stream(&scn); free(scn.sst_tab); break; default: @@ -1507,7 +1510,7 @@ main(int argc, char *argv[]) == -1) err(1, "Cannot read short stream"); #ifdef CDF_DEBUG - cdf_dump_stream(&h, &sst); + cdf_dump_stream(&sst); #endif #ifdef CDF_DEBUG diff --git a/src/cdf.h b/src/cdf.h index 853a7199..8b54f33a 100644 --- a/src/cdf.h +++ b/src/cdf.h @@ -336,7 +336,7 @@ char *cdf_u16tos8(char *, size_t, const uint16_t *); void cdf_dump_header(const cdf_header_t *); void cdf_dump_sat(const char *, const cdf_sat_t *, size_t); void cdf_dump(const void *, size_t); -void cdf_dump_stream(const cdf_header_t *, const cdf_stream_t *); +void cdf_dump_stream(const cdf_stream_t *); void cdf_dump_dir(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *, const cdf_dir_t *); void cdf_dump_property_info(const cdf_property_info_t *, size_t); diff --git a/src/readcdf.c b/src/readcdf.c index db8d3d39..7681672c 100644 --- a/src/readcdf.c +++ b/src/readcdf.c @@ -26,7 +26,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readcdf.c,v 1.57 2016/05/03 16:08:49 christos Exp $") +FILE_RCSID("@(#)$File: readcdf.c,v 1.58 2016/06/20 16:08:14 christos Exp $") #endif #include @@ -373,7 +373,7 @@ cdf_file_catalog_info(struct magic_set *ms, const cdf_info_t *info, dir, "Catalog", scn)) == -1) return i; #ifdef CDF_DEBUG - cdf_dump_catalog(&h, scn); + cdf_dump_catalog(h, scn); #endif if ((i = cdf_file_catalog(ms, h, scn)) == -1) return -1;