diff options
author | Christos Zoulas <christos@zoulas.com> | 2015-01-05 18:09:40 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2015-01-05 18:09:40 +0000 |
commit | 80a2ed983f386c6ef350b595d850a7f0084f946d (patch) | |
tree | 79c95df6966289ec0f9170f3332353eb3c93e1ed /src/cdf.c | |
parent | fc8f236fe060c74f5260c4cd4754e4e19eeed83d (diff) | |
download | file-git-80a2ed983f386c6ef350b595d850a7f0084f946d.tar.gz |
make sure we leave everything initialized.
Diffstat (limited to 'src/cdf.c')
-rw-r--r-- | src/cdf.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf.c,v 1.71 2015/01/05 18:00:36 christos Exp $") +FILE_RCSID("@(#)$File: cdf.c,v 1.72 2015/01/05 18:09:40 christos Exp $") #endif #include <assert.h> @@ -1002,8 +1002,10 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h, #define extract_catalog_field(t, f, l) \ - if (b + l + sizeof(cep->f) > eb) \ - break; \ + if (b + l + sizeof(cep->f) > eb) { \ + cep->ce_namlen = 0; \ + break; \ + } \ memcpy(&cep->f, b + (l), sizeof(cep->f)); \ ce[i].f = CAST(t, CDF_TOLE(cep->f)) @@ -1031,6 +1033,7 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, malloc(sizeof(cdf_catalog_t) + nr * sizeof(*ce))); (*cat)->cat_num = nr; ce = (*cat)->cat_e; + memset(ce, 0, nr * sizeof(*ce)); b = CAST(const char *, sst->sst_tab); for (i = 0; i < nr; i++, b += reclen) { cdf_catalog_entry_t *cep = &ce[i]; @@ -1043,7 +1046,6 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, if (reclen < 14) { cep->ce_namlen = 0; - cep->ce_name[0] = 0; continue; } @@ -1053,8 +1055,10 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, cep->ce_namlen = rlen; np = CAST(const uint16_t *, CAST(const void *, (b + 16))); - if (CAST(const char *, np + cep->ce_namlen) > eb) + if (CAST(const char *, np + cep->ce_namlen) > eb) { + cep->ce_namlen = 0; break; + } for (k = 0; k < cep->ce_namlen; k++) cep->ce_name[k] = np[k]; /* XXX: CDF_TOLE2? */ |