Skip to content

Commit

Permalink
Merge pull request #2125 from DennisHeimbigner/dmh-patches1.dmh
Browse files Browse the repository at this point in the history
Patch errors
  • Loading branch information
WardF authored Oct 12, 2021
2 parents 5cd17ba + 8bbdee1 commit 4c2adb5
Show file tree
Hide file tree
Showing 15 changed files with 325 additions and 227 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release

## 4.8.2 - TBD

* [Bug Fix] Apply patches for ezxml and for selected oss-fuzz detected errors. See [Github #2125](https://github.com/Unidata/netcdf-c/pull/2125).
* [Bug Fix] Ensure that internal Fortran APIs are always defined. See [Github #2098](https://github.com/Unidata/netcdf-c/pull/2098).
* [Enhancement] Support filters for NCZarr. See [Github #2101](https://github.com/Unidata/netcdf-c/pull/2101)
* [Bug Fix] Make PR 2075 long file name be idempotent. See [Github #2094](https://github.com/Unidata/netcdf-c/pull/2094).
Expand Down
2 changes: 1 addition & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nc4internal.h nctime.h nc3internal.h onstack.h ncrc.h ncauth.h \
ncoffsets.h nctestserver.h nc4dispatch.h nc3dispatch.h ncexternl.h \
ncpathmgr.h ncindex.h hdf4dispatch.h hdf5internal.h nc_provenance.h \
hdf5dispatch.h ncmodel.h isnan.h nccrc.h ncexhash.h ncxcache.h \
ncfilter.h ncjson.h
ncfilter.h ncjson.h ezxml.h

if USE_DAP
noinst_HEADERS += ncdap.h
Expand Down
61 changes: 34 additions & 27 deletions libdap4/ezxml.h → include/ezxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,69 +57,74 @@ struct ezxml {
/* structure. For efficiency, modifies the data by adding null terminators*/
/* and decoding ampersand sequences. If you don't want this, copy the data and*/
/* pass in the copy. Returns NULL on failure.*/
ezxml_t ezxml_parse_str(char *s, size_t len);

/* A wrapper for ezxml_parse_str() that accepts a file descriptor. First*/
/* attempts to mem map the file. Failing that, reads the file into memory.*/
/* Returns NULL on failure.*/
ezxml_t ezxml_parse_fd(int fd);

/* a wrapper for ezxml_parse_fd() that accepts a file name*/
ezxml_t ezxml_parse_file(const char *file);

/* Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire*/
/* stream into memory and then parses it. For xml files, use ezxml_parse_file()*/
/* or ezxml_parse_fd()*/
ezxml_t ezxml_parse_fp(FILE *fp);
ezxml_t nc_ezxml_parse_str(char *s, size_t len);

/* returns the first child tag (one level deeper) with the given name or NULL*/
/* if not found*/
ezxml_t ezxml_child(ezxml_t xml, const char *name);
ezxml_t nc_ezxml_child(ezxml_t xml, const char *name);

/* returns the next tag of the same name in the same section and depth or NULL*/
/* if not found*/
#define ezxml_next(xml) ((xml) ? xml->next : NULL)
#define nc_ezxml_next(xml) ((xml) ? (xml)->next : NULL)

/* Returns the Nth tag with the same name in the same section at the same depth*/
/* or NULL if not found. An index of 0 returns the tag given.*/
ezxml_t ezxml_idx(ezxml_t xml, int idx);
ezxml_t nc_ezxml_idx(ezxml_t xml, int idx);

/* returns the name of the given tag*/
#define ezxml_name(xml) ((xml) ? xml->name : NULL)
#define nc_ezxml_name(xml) ((xml) ? xml->name : NULL)

/* returns the given tag's character content or empty string if none*/
#define ezxml_txt(xml) ((xml) ? xml->txt : "")
#define nc_ezxml_txt(xml) ((xml) ? xml->txt : "")

/* returns the value of the requested tag attribute, or NULL if not found*/
const char *ezxml_attr(ezxml_t xml, const char *attr);
const char *nc_ezxml_attr(ezxml_t xml, const char *attr);

/* Traverses the ezxml structure to retrieve a specific subtag. Takes a*/
/* variable length list of tag names and indexes. The argument list must be*/
/* terminated by either an index of -1 or an empty string tag name. Example: */
/* title = ezxml_get(library, "shelf", 0, "book", 2, "title", -1);*/
/* This retrieves the title of the 3rd book on the 1st shelf of library.*/
/* Returns NULL if not found.*/
ezxml_t ezxml_get(ezxml_t xml, ...);
ezxml_t nc_ezxml_get(ezxml_t xml, ...);

/* Converts an ezxml structure back to xml. Returns a string of xml data that*/
/* must be freed.*/
char *ezxml_toxml(ezxml_t xml);
char *nc_ezxml_toxml(ezxml_t xml);

/* returns a NULL terminated array of processing instructions for the given*/
/* target*/
const char **ezxml_pi(ezxml_t xml, const char *target);
const char **nc_ezxml_pi(ezxml_t xml, const char *target);

/* frees the memory allocated for an ezxml structure*/
void ezxml_free(ezxml_t xml);
void nc_ezxml_free(ezxml_t xml);

/* returns parser error message or empty string if none*/
const char *ezxml_error(ezxml_t xml);
const char *nc_ezxml_error(ezxml_t xml);

const char** nc_ezxml_all_attr(ezxml_t xml, int* countp);


#if 0

/* returns a new empty ezxml structure with the given root tag name*/
ezxml_t ezxml_new(const char *name);
ezxml_t nc_ezxml_new(const char *name);

/* wrapper for ezxml_new() that strdup()s name*/
#define ezxml_new_d(name) ezxml_set_flag(ezxml_new(strdup(name)), EZXML_NAMEM)
#define nc_ezxml_new_d(name) ezxml_set_flag(ezxml_new(strdup(name)), EZXML_NAMEM)

/* A wrapper for ezxml_parse_str() that accepts a file descriptor. First*/
/* attempts to mem map the file. Failing that, reads the file into memory.*/
/* Returns NULL on failure.*/
ezxml_t ezxml_parse_fd(int fd);

/* a wrapper for ezxml_parse_fd() that accepts a file name*/
ezxml_t ezxml_parse_file(const char *file);

/* Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire*/
/* stream into memory and then parses it. For xml files, use ezxml_parse_file()*/
/* or ezxml_parse_fd()*/
ezxml_t ezxml_parse_fp(FILE *fp);

/* Adds a child tag. off is the offset of the child tag relative to the start*/
/* of the parent tag's character content. Returns the child tag.*/
Expand Down Expand Up @@ -160,6 +165,8 @@ ezxml_t ezxml_insert(ezxml_t xml, ezxml_t dest, size_t off);
/* removes a tag along with all its subtags*/
#define ezxml_remove(xml) ezxml_free(ezxml_cut(xml))

#endif /*0*/

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion libdap4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# University Corporation for Atmospheric Research/Unidata.

# See netcdf-c/COPYRIGHT file for more info.
SET(dap4_SOURCES d4curlfunctions.c d4fix.c d4data.c d4file.c d4parser.c d4meta.c d4varx.c d4dump.c d4swap.c d4chunk.c d4printer.c d4read.c d4http.c d4util.c d4odom.c d4cvt.c d4debug.c ncd4dispatch.c ezxml_extra.c ezxml.c)
SET(dap4_SOURCES d4curlfunctions.c d4fix.c d4data.c d4file.c d4parser.c d4meta.c d4varx.c d4dump.c d4swap.c d4chunk.c d4printer.c d4read.c d4http.c d4util.c d4odom.c d4cvt.c d4debug.c ncd4dispatch.c)

add_library(dap4 OBJECT ${dap4_SOURCES})

Expand Down
17 changes: 2 additions & 15 deletions libdap4/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ d4util.c \
d4odom.c \
d4cvt.c \
d4debug.c \
ncd4dispatch.c \
ezxml_extra.c \
ezxml.c
ncd4dispatch.c

HDRS= \
ncd4dispatch.h \
Expand All @@ -51,8 +49,7 @@ d4util.h \
d4debug.h \
d4odom.h \
d4bytes.h \
d4includes.h \
ezxml.h
d4includes.h

if ENABLE_DAP4
if USE_NETCDF4
Expand All @@ -67,13 +64,3 @@ libdap4_la_LIBADD =

endif # ENABLE_DAP4

# Show what is needed to insert a new version of ezxml
# primary fix: The original ezxml.[ch] uses '//' comments;
# unpack and replace with '/*..*/'
EZXML=ezxml-0.8.6.tar.gz
ezxml::
rm -fr ./ezxml ./ezxml.[ch] ./license.txt
tar -zxf ./${EZXML}
sed -e 's|//\(.*\)|/*\1*/|' <ezxml/ezxml.c >./ezxml.c
sed -e 's|//\(.*\)|/*\1*/|' <ezxml/ezxml.h >./ezxml.h
cp ezxml/license.txt .
Loading

0 comments on commit 4c2adb5

Please sign in to comment.