From 196841054c505e5b2149e90464c7d57922f0f9af Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 24 Dec 2021 11:25:00 +0900 Subject: [PATCH] Imported Upstream version 0.11.7 --- CMakeLists.txt | 20 ++++++++++++++++++-- ChangeLog | 13 +++++++++++++ INSTALL | 3 +++ RELEASE | 13 ++++++++++--- THANKS | 35 +++++++++++++++++++---------------- src/CMakeLists.txt | 23 +++++++++++++++++++++-- src/wbxml_encoder.c | 32 +++++++++++++++----------------- src/wbxml_tree.h | 2 +- test/api/test_wbxml_base64.c | 2 ++ test/api/test_wbxml_buffers.c | 3 +++ test/tools/launchTests.sh | 2 +- tools/wbxml2xml_tool.c | 4 ++-- tools/xml2wbxml_tool.c | 4 ++-- 13 files changed, 110 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbdad87..84bf55d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT( libwbxml C ) SET( LIBWBXML_VERSION_MAJOR "0" ) SET( LIBWBXML_VERSION_MINOR "11" ) -SET( LIBWBXML_VERSION_PATCH "6" ) +SET( LIBWBXML_VERSION_PATCH "7" ) IF( LIBWBXML_VERSION_BETA ) IF( LIBWBXML_VERSION_BETA VERSION_GREATER 90 ) MATH( EXPR LIBWBXML_VERSION_MINOR "${LIBWBXML_VERSION_MINOR} - 1" ) @@ -23,7 +23,7 @@ SET( LIBWBXML_LIBVERSION_CURRENT 1 ) # UPDATE: last release. # UPDATE: Set REVISION to 0 if any interface have been added, removed or # UPDATE: changed since the last update. -SET( LIBWBXML_LIBVERSION_REVISION 6 ) +SET( LIBWBXML_LIBVERSION_REVISION 7 ) # The difference between the newest and the oldest interfaces. # UPDATE: If any interface have been added since the last public @@ -37,6 +37,20 @@ MATH( EXPR LIBWBXML_LIBVERSION_SOVERSION "${LIBWBXML_LIBVERSION_CURRENT} - ${LIB SET( LIBWBXML_LIBVERSION_VERSION "${LIBWBXML_LIBVERSION_SOVERSION}.${LIBWBXML_LIBVERSION_AGE}.${LIBWBXML_LIBVERSION_REVISION}" ) +# this hack protects the SO versioning of the library +# it makes the exposing of internal header files possible and safe +# usual library version: 2.6.1 +# special library version: 20601.0.0 +IF( WBXML_INSTALL_FULL_HEADERS ) + + # calculate big major version + MATH( EXPR LIBWBXML_LIBVERSION_SOVERSION "10000 * ${LIBWBXML_LIBVERSION_SOVERSION} + 100 * ${LIBWBXML_LIBVERSION_AGE} + ${LIBWBXML_LIBVERSION_REVISION}" ) + + # build a x.0.0 version + SET( LIBWBXML_LIBVERSION_VERSION "${LIBWBXML_LIBVERSION_SOVERSION}.0.0" ) + +ENDIF( WBXML_INSTALL_FULL_HEADERS ) + CMAKE_MINIMUM_REQUIRED(VERSION 2.4) # TODO: Move to external file/macro @@ -151,6 +165,7 @@ OPTION( WBXML_SUPPORT_SYNCML "enable SYNCML support" ON ) OPTION( WBXML_SUPPORT_WV "enable WV support" ON ) OPTION( WBXML_SUPPORT_AIRSYNC "enable AIRSYNC support" ON ) OPTION( WBXML_SUPPORT_CONML "enable Nokia ConML support" ON ) +OPTION( WBXML_INSTALL_FULL_HEADERS "install internal headers" OFF ) SET( PACKAGE "libwbxml" ) SET( PACKAGE_BUGREPORT " " ) @@ -233,6 +248,7 @@ SHOW_STATUS( WBXML_SUPPORT_CONML "enable Nokia ConML support\t" ) SHOW_STATUS( BUILD_DOCUMENTATION "build dynamic documentation\t" ) SHOW_STATUS( WBXML_SUPPORT_ICONV "enable iconv support\t\t" ) SHOW_STATUS( ENABLE_INSTALL_DOC "install documentation\t" ) +SHOW_STATUS( WBXML_INSTALL_FULL_HEADERS "install internal headers\t" ) # fatal error detection IF ( FATAL_ERROR_EXPAT ) diff --git a/ChangeLog b/ChangeLog index 396b04b..dfb0ace 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2020-04-15 Michael Bell + * Released 0.11.7 + * Added WBXML_INSTALL_FULL_HEADERS cmake flag to expose internal API + headers; changes version for compatibility (e.g. 2.6.1 -> 20601.0.0) + (pull request #67 from David Llewellyn-Jones) + * Link to libexpat correctly (private). Therefore the tools wbxml2xml + and xml2wbxml do no longer link directly to libexpat. + (pull request #65 from Peter Keresztes Schmidt) + * During build use headers which come with source code and not the + installed headers. (pull request #66 from David Llewellyn-Jones) + * Fixed several memory leaks and leak-sanitizer issues. + (pull requests #61, #62, #63 and #64 from Gaurav Gupta) + 2017-08-15 Michael Bell * Released 0.11.6 * Fixed/changed the encoding of element Content in CodePage diff --git a/INSTALL b/INSTALL index dc84e60..b2a1e21 100644 --- a/INSTALL +++ b/INSTALL @@ -74,8 +74,11 @@ WBXML_SUPPORT_OTA_SETTINGS : Support of Ericsson / Nokia OTA Settings v7.0 WBXML_SUPPORT_SYNCML : Support of SyncML 1.0 / SyncML 1.1 / SyncML 1.2 WBXML_SUPPORT_WV : Support of Wireless-Village CSP 1.1 / CSP 1.2 + WBXML_SUPPORT_AIRSYNC : Support of AIRSYNC 2.5 + WBXML_SUPPORT_CONML : Support of Nokia ConML HAVE_EXPAT : Enable XML Parsing feature (needs Expat) + WBXML_INSTALL_FULL_HEADERS : Install unstable internal API headers BUILD_SHARED_LIBS : Build wbxml as shared library BUILD_STATIC_LIBS : Build wbxml as static library diff --git a/RELEASE b/RELEASE index 2be69a2..c6aad7e 100644 --- a/RELEASE +++ b/RELEASE @@ -31,7 +31,15 @@ To make a release of libwbxml, do the following: "make" "make test" - - Commit and push the increased version changes (and build fixes) + - Check ChangeLog to be complete and add the new release name. + + - Final steps with git: + git pull origin + git pull upstream master + git status + git commit -a + git tag libwbxml-$MAJOR.$MINOR.$PATCH + git push origin libwbxml-$MAJOR.$MINOR.$PATCH - if someone else made changes and the push fails, you have to "git pull" and run the tests again @@ -39,9 +47,8 @@ To make a release of libwbxml, do the following: - please run "git status" before you continue to be 100 percent sure that there is no forgotten commit and no unrevisioned file. - - Check ChangeLog to be complete and add the new release name. - - Once the commit succeeds, you have to create a new release on GitHub. + Please create a pull request from your fork. Please use the web GUI of Github and write some useful release notes. - create tarballs for an out-of-source-build with diff --git a/THANKS b/THANKS index 91c087a..2ec9664 100644 --- a/THANKS +++ b/THANKS @@ -8,22 +8,25 @@ Michael Bell The following people helped to develop and maintain this library: -Amnon Aaronsohn (ActiveSync) -Pau Aliagas -Michael Banck (Debian package maintainer, testing) -Michael Bell -Gaurav Gupta -Gil Hartmann (Active Sync v16.0) -Conrad Irwin (performance fixes) -Aymerick Jehanne -Ossi Jormakka (Ixonos Plc., ActiveSync) -Anton D. Kachalov (Nokia ConML support) -Benedykt Kroplewski -Jeremy Lainé (helped with cmake on Win32) -Mark Ostrer (Websense) -Petr Písař (RedHat/Fedora package maintainer) -Renu Tyagi (fixed some memory leaks) -Boaz Yaniv (MS Visual Studio fixes) +Amnon Aaronsohn (ActiveSync) +Pau Aliagas +Michael Banck (Debian package maintainer, testing) +Michael Bell +Gaurav Gupta +Gil Hartmann (Active Sync v16.0) +Conrad Irwin (performance fixes) +Aymerick Jehanne +Ossi Jormakka (Ixonos Plc., ActiveSync) +Anton D. Kachalov (Nokia ConML support) +Peter Keresztes Schmidt (fixed libexpat linking) +Benedykt Kroplewski +Jeremy Lainé (helped with cmake on Win32) +Mark Ostrer (Websense) +Petr Písař (RedHat/Fedora package maintainer) +Renu Tyagi (fixed some memory leaks) +Boaz Yaniv (MS Visual Studio fixes) +Slava Monich +David Llewellyn-Jones If you think your name is missing here then please feel free to create a ticket. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 33a8d72..33bd54b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,7 @@ IF(BUILD_SHARED_LIBS) SET_TARGET_PROPERTIES( wbxml2 PROPERTIES SOVERSION ${LIBWBXML_LIBVERSION_SOVERSION} ) SET_TARGET_PROPERTIES( wbxml2 PROPERTIES VERSION ${LIBWBXML_LIBVERSION_VERSION} ) - TARGET_LINK_LIBRARIES( wbxml2 ${EXPAT_LIBRARIES} ) + TARGET_LINK_LIBRARIES( wbxml2 PRIVATE ${EXPAT_LIBRARIES} ) INSTALL( TARGETS wbxml2 RUNTIME DESTINATION ${LIBWBXML_BIN_DIR} @@ -44,7 +44,7 @@ IF(BUILD_STATIC_LIBS) SET_TARGET_PROPERTIES( wbxml2_static PROPERTIES SOVERSION ${LIBWBXML_LIBVERSION_SOVERSION} ) SET_TARGET_PROPERTIES( wbxml2_static PROPERTIES VERSION ${LIBWBXML_LIBVERSION_VERSION} ) - TARGET_LINK_LIBRARIES( wbxml2_static ${EXPAT_LIBRARIES} ) + TARGET_LINK_LIBRARIES( wbxml2_static PRIVATE ${EXPAT_LIBRARIES} ) SET_TARGET_PROPERTIES( wbxml2_static PROPERTIES OUTPUT_NAME wbxml2 ) INSTALL( TARGETS wbxml2_static @@ -64,3 +64,22 @@ INSTALL( FILES DESTINATION ${LIBWBXML_INCLUDE_DIR}/wbxml ) +IF(WBXML_INSTALL_FULL_HEADERS) + INSTALL( FILES + wbxml_base64.h + wbxml_buffers.h + wbxml_charset.h + wbxml_elt.h + wbxml_encoder.h + wbxml_handlers.h + wbxml_lists.h + wbxml_log.h + wbxml_mem.h + wbxml_parser.h + wbxml_tables.h + wbxml_tree.h + wbxml_tree_clb_wbxml.h + wbxml_tree_clb_xml.h + DESTINATION ${LIBWBXML_INCLUDE_DIR}/wbxml + ) +ENDIF() diff --git a/src/wbxml_encoder.c b/src/wbxml_encoder.c index cd2d6bc..c73780f 100644 --- a/src/wbxml_encoder.c +++ b/src/wbxml_encoder.c @@ -3177,7 +3177,6 @@ static WBXMLError wbxml_encode_wv_datetime_inline(WBXMLEncoder *encoder, WB_UTIN */ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTINY *buffer) { - WBXMLError error; WBXMLBuffer *tmp = NULL; WB_ULONG i = 0, len = 0; WB_UTINY ch = 0; @@ -3192,7 +3191,7 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Create temp Buffer */ if ((tmp = wbxml_buffer_create_from_cstr(buffer)) == NULL) { - error = WBXML_ERROR_NOT_ENOUGH_MEMORY; + ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; goto error; } @@ -3211,26 +3210,26 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN } if ((len != 15) && (len != 16)) { WBXML_ERROR((WBXML_CONV, "The length of a WV datetime must be 15 or 16.")); - error = WBXML_ERROR_WV_DATETIME_FORMAT; + ret = WBXML_ERROR_WV_DATETIME_FORMAT; goto error; } /* Check position of 'T' */ if (*(buffer+8) != 'T') { WBXML_ERROR((WBXML_CONV, "The 9th character of a WV datetime must be 'T'.")); - error = WBXML_ERROR_WV_DATETIME_FORMAT; + ret = WBXML_ERROR_WV_DATETIME_FORMAT; goto error; } /* Check position of time zone */ if (len == 16) { if (!wbxml_buffer_get_char(tmp, 15, &ch)) { - error = WBXML_ERROR_INTERNAL; + ret = WBXML_ERROR_INTERNAL; goto error; } if (ch < 'A' || ch == 'J' || ch > 'Z') { WBXML_ERROR((WBXML_CONV, "If the length of a WV datetime is 16 then the last character must be the time zone.")); - error = WBXML_ERROR_WV_DATETIME_FORMAT; + ret = WBXML_ERROR_WV_DATETIME_FORMAT; goto error; } @@ -3251,12 +3250,12 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN while (i < wbxml_buffer_len(tmp)) { /* Get char */ if (!wbxml_buffer_get_char(tmp, i, &ch)) { - error = WBXML_ERROR_INTERNAL; + ret = WBXML_ERROR_INTERNAL; goto error; } if (!WBXML_ISDIGIT(ch)) { - error = WBXML_ERROR_WV_DATETIME_FORMAT; + ret = WBXML_ERROR_WV_DATETIME_FORMAT; goto error; } else @@ -3268,7 +3267,7 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Set Year */ component = wbxml_buffer_duplicate(tmp); if (!component) { - error = WBXML_ERROR_NOT_ENOUGH_MEMORY; + ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; goto error; } wbxml_buffer_delete(component, 4, 10); @@ -3280,7 +3279,7 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Set Month */ component = wbxml_buffer_duplicate(tmp); if (!component) { - error = WBXML_ERROR_NOT_ENOUGH_MEMORY; + ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; goto error; } wbxml_buffer_delete(component, 0, 4); @@ -3294,7 +3293,7 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Set Day */ component = wbxml_buffer_duplicate(tmp); if (!component) { - error = WBXML_ERROR_NOT_ENOUGH_MEMORY; + ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; goto error; } wbxml_buffer_delete(component, 0, 6); @@ -3307,7 +3306,7 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Set Hour */ component = wbxml_buffer_duplicate(tmp); if (!component) { - error = WBXML_ERROR_NOT_ENOUGH_MEMORY; + ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; goto error; } wbxml_buffer_delete(component, 0, 8); @@ -3321,7 +3320,7 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Set Minute */ component = wbxml_buffer_duplicate(tmp); if (!component) { - error = WBXML_ERROR_NOT_ENOUGH_MEMORY; + ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; goto error; } wbxml_buffer_delete(component, 0, 10); @@ -3335,7 +3334,7 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Set Second */ component = wbxml_buffer_duplicate(tmp); if (!component) { - error = WBXML_ERROR_NOT_ENOUGH_MEMORY; + ret = WBXML_ERROR_NOT_ENOUGH_MEMORY; goto error; } wbxml_buffer_delete(component, 0, 12); @@ -3348,12 +3347,11 @@ static WBXMLError wbxml_encode_wv_datetime_opaque(WBXMLEncoder *encoder, WB_UTIN /* Encode it to Opaque */ ret = wbxml_encode_opaque_data(encoder, octets, 6); - - return ret; + error: if (tmp) wbxml_buffer_destroy(tmp); - return error; + return ret; } diff --git a/src/wbxml_tree.h b/src/wbxml_tree.h index 3c5a6ad..8f7dfc9 100644 --- a/src/wbxml_tree.h +++ b/src/wbxml_tree.h @@ -43,7 +43,7 @@ extern "C" { #endif /* __cplusplus */ -#include +#include "wbxml_config.h" /** @addtogroup wbxml_tree * @{ diff --git a/test/api/test_wbxml_base64.c b/test/api/test_wbxml_base64.c index c22b59c..61ce5af 100644 --- a/test/api/test_wbxml_base64.c +++ b/test/api/test_wbxml_base64.c @@ -34,7 +34,9 @@ START_TEST (test_decode) ck_assert(wbxml_base64_decode(NULL, 0, &result) <= 0); ck_assert(wbxml_base64_decode(NULL, 1, &result) <= 0); ck_assert(wbxml_base64_decode((const WB_UTINY*) "", 0, &result) <= 0); + wbxml_free(result); ck_assert(wbxml_base64_decode((const WB_UTINY*) "test", 0, &result) <= 0); + wbxml_free(result); /* decode a string */ diff --git a/test/api/test_wbxml_buffers.c b/test/api/test_wbxml_buffers.c index 01ce636..a541c0b 100644 --- a/test/api/test_wbxml_buffers.c +++ b/test/api/test_wbxml_buffers.c @@ -78,6 +78,7 @@ START_TEST (test_init_and_destroy_static) ck_assert( ! wbxml_buffer_remove_trailing_zeros(buf)); + wbxml_buffer_destroy(buf2); wbxml_buffer_destroy(buf); } END_TEST @@ -237,6 +238,7 @@ START_TEST (test_insert) ck_assert(wbxml_buffer_insert(buf, buf2, 3)); ck_assert(wbxml_buffer_len(buf) == 12); ck_assert(wbxml_buffer_compare_cstr(buf, "123XYZtes7t9") == 0); + wbxml_buffer_destroy(buf2); wbxml_buffer_destroy(buf); } @@ -332,6 +334,7 @@ START_TEST (test_compare) ck_assert(wbxml_buffer_compare(buf, buf2) != 0); ck_assert(wbxml_buffer_compare_cstr(buf, "test") != 0); + wbxml_buffer_destroy(buf2); wbxml_buffer_destroy(buf); } END_TEST diff --git a/test/tools/launchTests.sh b/test/tools/launchTests.sh index 107c9e7..5757dd4 100755 --- a/test/tools/launchTests.sh +++ b/test/tools/launchTests.sh @@ -45,7 +45,7 @@ fi # Debian does this by default if [ "${CMAKE_SKIP_RPATH}" ] then - LD_LIBRARY_PATH="${CMAKE_CURRENT_BINARY_DIR}/../../src" + LD_LIBRARY_PATH="${CMAKE_CURRENT_BINARY_DIR}/../../src:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH fi diff --git a/tools/wbxml2xml_tool.c b/tools/wbxml2xml_tool.c index 415d46d..3fde0e1 100644 --- a/tools/wbxml2xml_tool.c +++ b/tools/wbxml2xml_tool.c @@ -367,14 +367,14 @@ WB_LONG main(WB_LONG argc, WB_TINY **argv) case '?': default: help(); - return 0; + goto clean_up; } } if (optind >= argc) { fprintf(stderr, "Missing arguments\n"); help(); - return 0; + goto clean_up; } #ifdef WBXML_USE_LEAKTRACKER diff --git a/tools/xml2wbxml_tool.c b/tools/xml2wbxml_tool.c index 4c0b646..6186bea 100644 --- a/tools/xml2wbxml_tool.c +++ b/tools/xml2wbxml_tool.c @@ -146,14 +146,14 @@ WB_LONG main(WB_LONG argc, WB_TINY **argv) case '?': default: help(); - return 0; + goto clean_up; } } if (optind >= argc) { fprintf(stderr, "Missing arguments\n"); help(); - return 0; + goto clean_up; } #ifdef WBXML_USE_LEAKTRACKER -- 2.34.1