You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/01/23 22:28:15 UTC
(axis-axis2-c-core) branch master updated (e62d9945f -> 9a69106e9)
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
from e62d9945f Fix use-after-free when replacing svc_client options (AXIS2C-1355)
new 055eb8d5b Fix last POST parameter skipped when it has no value (AXIS2C-1532)
new e2d96d887 Remove broken and unused axutil_strtol/axutil_strtoul functions (AXIS2C-1508)
new 9ca40ebf1 Add default namespace undeclaration for elements without namespace (AXIS2C-1275)
new 7010c6e3f Fix ASAN preload issue for libtool-wrapped tests
new 9a69106e9 Fix test_deployment by creating axis2.xml symlink and disabling addressing module
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
Makefile.am | 4 +
axiom/configure.ac | 28 +++
axiom/src/om/om_element.c | 40 ++++
axiom/test/om/Makefile.am | 5 +
axiom/test/om/test_om.cc | 101 +++++++++
axiom/test/parser/Makefile.am | 5 +
axiom/test/soap/Makefile.am | 5 +
axiom/test/util/Makefile.am | 5 +
axiom/test/xpath/Makefile.am | 5 +
configure.ac | 32 ++-
guththila/configure.ac | 29 +++
guththila/tests/Makefile.am | 5 +
neethi/configure.ac | 28 +++
neethi/test/Makefile.am | 5 +
samples/server/axis2.xml | 4 +-
src/core/transport/h2/test/Makefile.am | 5 +
.../transport/http/util/http_transport_utils.c | 6 +-
test/core/addr/Makefile.am | 6 +
test/core/clientapi/Makefile.am | 6 +
test/core/context/Makefile.am | 6 +
test/core/deployment/Makefile.am | 6 +
test/core/description/Makefile.am | 6 +
test/core/engine/Makefile.am | 5 +
test/core/transport/http/Makefile.am | 40 +++-
test/core/transport/http/test_axis2c_1532.cc | 252 +++++++++++++++++++++
util/configure.ac | 28 +++
util/include/axutil_types.h | 17 --
util/src/types.c | 42 ----
util/test/utils/Makefile.am | 5 +
29 files changed, 665 insertions(+), 66 deletions(-)
create mode 100644 test/core/transport/http/test_axis2c_1532.cc
(axis-axis2-c-core) 03/05: Add default namespace undeclaration for elements without namespace (AXIS2C-1275)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 9ca40ebf13e51dcac14edfbb0e3bac7ec2a6d7c4
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Fri Jan 23 11:46:06 2026 -1000
Add default namespace undeclaration for elements without namespace (AXIS2C-1275)
When creating an element with NULL namespace under a parent that has a
default namespace (xmlns="..."), the child element now gets an explicit
xmlns="" declaration to undeclare the inherited default namespace.
This ensures correct XML namespace semantics and proper canonicalization
for XML signatures. Previously, a child with NULL namespace would
serialize without xmlns="", causing XML processors to interpret it as
inheriting the parent's default namespace, which differs from the
internal AXIOM representation.
The fix is based on the Java Axiom implementation in NSUtil.handleNamespace()
which handles this same case by adding a default namespace undeclaration.
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
axiom/src/om/om_element.c | 40 ++++++++++++++++++
axiom/test/om/test_om.cc | 101 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 141 insertions(+)
diff --git a/axiom/src/om/om_element.c b/axiom/src/om/om_element.c
index 94b9ca89e..f7c47d69d 100644
--- a/axiom/src/om/om_element.c
+++ b/axiom/src/om/om_element.c
@@ -126,6 +126,46 @@ axiom_element_create(
return NULL;
}
}
+ else if (parent)
+ {
+ /* AXIS2C-1275: When creating an element without namespace under a parent that has
+ * a default namespace in scope, we need to explicitly undeclare the default namespace
+ * by adding xmlns="" to the new element. This ensures correct XML namespace semantics
+ * and proper canonicalization for XML signatures.
+ *
+ * This fix is based on the Java Axiom implementation in NSUtil.handleNamespace()
+ * (ws-axiom/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/common/NSUtil.java)
+ * which adds a default namespace undeclaration when:
+ * - Creating an element (not attribute)
+ * - With no namespace (null)
+ * - Under a parent that has a default namespace with non-empty URI
+ *
+ * See also: TestCreateOMElementWithoutNamespace2.java in Java Axiom test suite
+ */
+ if (axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT)
+ {
+ axiom_element_t *parent_ele = axiom_node_get_data_element(parent, env);
+ if (parent_ele)
+ {
+ axiom_namespace_t *default_ns = axiom_element_get_default_namespace(parent_ele, env, parent);
+ if (default_ns)
+ {
+ axis2_char_t *default_uri = axiom_namespace_get_uri(default_ns, env);
+ if (default_uri && axutil_strcmp(default_uri, "") != 0)
+ {
+ /* Parent has a non-empty default namespace - undeclare it with xmlns="" */
+ axiom_namespace_t *undeclare_ns = axiom_namespace_create(env, "", "");
+ if (undeclare_ns)
+ {
+ axiom_element_declare_namespace(element, env, *node, undeclare_ns);
+ /* declare_namespace increments ref count, so free our reference */
+ axiom_namespace_free(undeclare_ns, env);
+ }
+ }
+ }
+ }
+ }
+ }
return element;
}
diff --git a/axiom/test/om/test_om.cc b/axiom/test/om/test_om.cc
index 1dc148cdd..95f5fc37b 100644
--- a/axiom/test/om/test_om.cc
+++ b/axiom/test/om/test_om.cc
@@ -453,3 +453,104 @@ TEST_F(TestOM, test_attribute)
}
+
+/**
+ * AXIS2C-1275: Test that creating a child element without namespace under a parent
+ * with a default namespace results in an xmlns="" declaration on the child.
+ *
+ * This test is based on TestCreateOMElementWithoutNamespace2.java from the Java Axiom
+ * test suite (ws-axiom/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/factory/).
+ *
+ * The scenario:
+ * <parent xmlns="http://example.org/">
+ * <child xmlns="">text</child> <!-- should have xmlns="" to undeclare default ns -->
+ * </parent>
+ *
+ * Without the fix, the child would serialize as <child> without xmlns="", which according
+ * to XML namespace rules would mean the child inherits the parent's default namespace.
+ * This causes XML signature verification failures because the canonicalized form differs.
+ */
+TEST_F(TestOM, test_axis2c_1275_default_namespace_undeclare)
+{
+ axiom_namespace_t *parent_ns = NULL;
+ axiom_element_t *parent_ele = NULL;
+ axiom_element_t *child_ele = NULL;
+ axiom_node_t *parent_node = NULL;
+ axiom_node_t *child_node = NULL;
+ axiom_xml_writer_t *writer = NULL;
+ axiom_output_t *om_output = NULL;
+ axis2_char_t *output_buffer = NULL;
+ axutil_hash_t *child_namespaces = NULL;
+ axiom_namespace_t *undeclare_ns = NULL;
+
+ printf("\nstart test_axis2c_1275_default_namespace_undeclare\n");
+
+ /* Create parent element with default namespace (empty prefix, non-empty URI) */
+ parent_ns = axiom_namespace_create(m_env, "http://example.org/", "");
+ ASSERT_NE(parent_ns, nullptr);
+
+ parent_ele = axiom_element_create(m_env, NULL, "parent", parent_ns, &parent_node);
+ ASSERT_NE(parent_ele, nullptr);
+ ASSERT_NE(parent_node, nullptr);
+
+ /* Create child element WITHOUT namespace under the parent with default namespace */
+ child_ele = axiom_element_create(m_env, parent_node, "child", NULL, &child_node);
+ ASSERT_NE(child_ele, nullptr);
+ ASSERT_NE(child_node, nullptr);
+
+ /* Verify child element has an empty default namespace (xmlns="") */
+ axiom_namespace_t *child_ns = axiom_element_get_namespace(child_ele, m_env, child_node);
+ /* With our fix, get_namespace returns the xmlns="" undeclaration.
+ * The child is effectively in "no namespace", indicated by empty URI. */
+ ASSERT_NE(child_ns, nullptr);
+ axis2_char_t *child_ns_uri = axiom_namespace_get_uri(child_ns, m_env);
+ ASSERT_NE(child_ns_uri, nullptr);
+ ASSERT_STREQ("", child_ns_uri); /* Empty URI means no namespace */
+
+ /* Verify child element has xmlns="" namespace declaration */
+ child_namespaces = axiom_element_get_namespaces(child_ele, m_env);
+ ASSERT_NE(child_namespaces, nullptr);
+
+ /* Look for the default namespace declaration (empty prefix key) */
+ undeclare_ns = (axiom_namespace_t *)axutil_hash_get(child_namespaces, "", AXIS2_HASH_KEY_STRING);
+ ASSERT_NE(undeclare_ns, nullptr);
+
+ /* Verify it's an undeclaration (empty prefix, empty URI) */
+ axis2_char_t *undeclare_prefix = axiom_namespace_get_prefix(undeclare_ns, m_env);
+ axis2_char_t *undeclare_uri = axiom_namespace_get_uri(undeclare_ns, m_env);
+ /* Prefix may be NULL or empty string */
+ if (undeclare_prefix != NULL) {
+ ASSERT_STREQ("", undeclare_prefix);
+ }
+ ASSERT_NE(undeclare_uri, nullptr);
+ ASSERT_STREQ("", undeclare_uri);
+
+ /* Set text content for child */
+ axiom_element_set_text(child_ele, m_env, "text", child_node);
+
+ /* Serialize and verify output contains xmlns="" */
+ writer = axiom_xml_writer_create_for_memory(m_env, NULL, AXIS2_TRUE, 0,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ ASSERT_NE(writer, nullptr);
+
+ om_output = axiom_output_create(m_env, writer);
+ ASSERT_NE(om_output, nullptr);
+
+ axis2_status_t status = axiom_node_serialize(parent_node, m_env, om_output);
+ ASSERT_EQ(status, AXIS2_SUCCESS);
+
+ output_buffer = (axis2_char_t *)axiom_xml_writer_get_xml(writer, m_env);
+ ASSERT_NE(output_buffer, nullptr);
+
+ printf("Serialized XML: %s\n", output_buffer);
+
+ /* Verify the output contains xmlns="" on the child element */
+ ASSERT_NE(strstr(output_buffer, "xmlns=\"\""), nullptr);
+
+ /* Clean up */
+ axiom_output_free(om_output, m_env);
+ axiom_node_free_tree(parent_node, m_env);
+ axiom_namespace_free(parent_ns, m_env);
+
+ printf("\nend test_axis2c_1275_default_namespace_undeclare\n");
+}
(axis-axis2-c-core) 05/05: Fix test_deployment by creating axis2.xml symlink and disabling addressing module
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 9a69106e9bb7e518d08d64443fbc22e669f28b36
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Fri Jan 23 12:20:26 2026 -1000
Fix test_deployment by creating axis2.xml symlink and disabling addressing module
The deployment engine expects axis2.xml at $AXIS2C_HOME/axis2.xml, but it was
installed at $AXIS2C_HOME/share/axis2c/axis2.xml. Added symlink creation in
install-data-hook to make axis2.xml accessible from the expected location.
Also commented out the addressing module reference in axis2.xml since no
addressing module is deployed in the default configuration. Users who install
the addressing module can uncomment this line.
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
Makefile.am | 4 ++++
samples/server/axis2.xml | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index f0276251c..5f3f09803 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -109,6 +109,10 @@ install-data-hook:
echo "Skipping $$file - already in correct location"; \
fi; \
done
+ @echo "Creating axis2.xml symlink at $(DESTDIR)$(prefix) for deployment engine compatibility"
+ @rm -f $(DESTDIR)$(prefix)/axis2.xml 2>/dev/null || true
+ @cd $(DESTDIR)$(prefix) && $(LN_S) share/axis2c/axis2.xml axis2.xml 2>/dev/null || \
+ echo "Note: Could not create axis2.xml symlink (may already exist or different filesystem)"
@echo ""
@echo "========================================================================"
@echo "CRITICAL: Complete Apache Module & Library Deployment Required!"
diff --git a/samples/server/axis2.xml b/samples/server/axis2.xml
index 47bbf4d1f..6624dd6ae 100644
--- a/samples/server/axis2.xml
+++ b/samples/server/axis2.xml
@@ -103,8 +103,8 @@
<!-- ================================================= -->
<!-- Global Modules -->
<!-- ================================================= -->
- <!-- Comment this to disable Addressing -->
- <module ref="addressing"/>
+ <!-- Uncomment this to enable Addressing module (requires addressing module to be deployed) -->
+ <!--<module ref="addressing"/>-->
<!--Configuring module , providing paramters for modules whether they refer or not-->
(axis-axis2-c-core) 04/05: Fix ASAN preload issue for libtool-wrapped tests
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 7010c6e3fd2761152405dd873f1073694e8207f5
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Fri Jan 23 12:05:38 2026 -1000
Fix ASAN preload issue for libtool-wrapped tests
When running tests with ASAN enabled via `make check`, libtool wrapper
scripts would load libraries before ASAN, causing the error:
"ASan runtime does not come first in initial library list"
This fix adds TESTS_ENVIRONMENT with LD_PRELOAD to force ASAN to be
loaded first when tests run. The ASAN library path is auto-detected
during configure.
Changes:
- Add ENABLE_ASAN automake conditional to all configure.ac files
- Add ASAN_PRELOAD library path detection (checks common locations)
- Add conditional TESTS_ENVIRONMENT to all test Makefile.am files
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
axiom/configure.ac | 28 ++++++++++++++++++++++++++++
axiom/test/om/Makefile.am | 5 +++++
axiom/test/parser/Makefile.am | 5 +++++
axiom/test/soap/Makefile.am | 5 +++++
axiom/test/util/Makefile.am | 5 +++++
axiom/test/xpath/Makefile.am | 5 +++++
configure.ac | 32 +++++++++++++++++++++++++++++++-
guththila/configure.ac | 29 +++++++++++++++++++++++++++++
guththila/tests/Makefile.am | 5 +++++
neethi/configure.ac | 28 ++++++++++++++++++++++++++++
neethi/test/Makefile.am | 5 +++++
src/core/transport/h2/test/Makefile.am | 5 +++++
test/core/addr/Makefile.am | 6 ++++++
test/core/clientapi/Makefile.am | 6 ++++++
test/core/context/Makefile.am | 6 ++++++
test/core/deployment/Makefile.am | 6 ++++++
test/core/description/Makefile.am | 6 ++++++
test/core/engine/Makefile.am | 5 +++++
test/core/transport/http/Makefile.am | 5 +++++
util/configure.ac | 28 ++++++++++++++++++++++++++++
util/test/utils/Makefile.am | 5 +++++
21 files changed, 229 insertions(+), 1 deletion(-)
diff --git a/axiom/configure.ac b/axiom/configure.ac
index c8db16746..5980234f5 100644
--- a/axiom/configure.ac
+++ b/axiom/configure.ac
@@ -202,11 +202,13 @@ AC_ARG_ENABLE(asan, [ --enable-asan
[ case "${enableval}" in
no)
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"
;;
*)
AC_MSG_RESULT(yes)
+ enable_asan=yes
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
CPPFLAGS="$CPPFLAGS -fsanitize=address -fno-omit-frame-pointer"
CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-omit-frame-pointer"
@@ -215,10 +217,36 @@ AC_ARG_ENABLE(asan, [ --enable-asan
;;
esac ],[
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"]
)
+dnl Create automake conditional for ASAN (used by test Makefile.am for LD_PRELOAD)
+AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
+
+dnl Detect ASAN library path for test preloading (libtool-wrapped tests need this)
+ASAN_PRELOAD=""
+if test "x$enable_asan" = "xyes"; then
+ AC_MSG_CHECKING([for ASAN library path])
+ for asan_path in /lib/x86_64-linux-gnu/libasan.so.8 \
+ /lib/x86_64-linux-gnu/libasan.so.6 \
+ /lib64/libasan.so.8 \
+ /lib64/libasan.so.6 \
+ /usr/lib/libasan.so; do
+ if test -f "$asan_path"; then
+ ASAN_PRELOAD="$asan_path"
+ break
+ fi
+ done
+ if test -n "$ASAN_PRELOAD"; then
+ AC_MSG_RESULT([$ASAN_PRELOAD])
+ else
+ AC_MSG_RESULT([not found - tests may fail with libtool wrappers])
+ fi
+fi
+AC_SUBST([ASAN_PRELOAD])
+
AC_MSG_CHECKING(whether to use the Google test framework)
AC_ARG_WITH(gtest,
diff --git a/axiom/test/om/Makefile.am b/axiom/test/om/Makefile.am
index 1c75c157b..16dea26f1 100644
--- a/axiom/test/om/Makefile.am
+++ b/axiom/test/om/Makefile.am
@@ -21,6 +21,11 @@ TESTS = test_om
noinst_PROGRAMS = test_om
check_PROGRAMS = test_om
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
test_om_SOURCES = test_om.cc
test_om_LDADD = $(top_builddir)/../util/src/libaxutil.la \
diff --git a/axiom/test/parser/Makefile.am b/axiom/test/parser/Makefile.am
index f3cbbb657..7ea112e44 100644
--- a/axiom/test/parser/Makefile.am
+++ b/axiom/test/parser/Makefile.am
@@ -21,6 +21,11 @@ TESTS = test_parser
noinst_PROGRAMS = test_parser
check_PROGRAMS = test_parser
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
test_parser_SOURCES = test_parser.cc
test_parser_LDADD = $(top_builddir)/../util/src/libaxutil.la \
diff --git a/axiom/test/soap/Makefile.am b/axiom/test/soap/Makefile.am
index 9f3505abb..1812e78fa 100644
--- a/axiom/test/soap/Makefile.am
+++ b/axiom/test/soap/Makefile.am
@@ -22,6 +22,11 @@ noinst_PROGRAMS = test_soap
check_PROGRAMS = test_soap
AM_CFLAGS = -g -O2
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
test_soap_SOURCES = test_soap.cc
test_soap_LDADD = $(top_builddir)/../util/src/libaxutil.la \
diff --git a/axiom/test/util/Makefile.am b/axiom/test/util/Makefile.am
index 06205aa95..8870053e7 100644
--- a/axiom/test/util/Makefile.am
+++ b/axiom/test/util/Makefile.am
@@ -21,6 +21,11 @@ TESTS = test_util
check_PROGRAMS = test_util
noinst_PROGRAMS = test_util
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
test_util_SOURCES = test_util.cc
test_util_LDADD = \
diff --git a/axiom/test/xpath/Makefile.am b/axiom/test/xpath/Makefile.am
index 2e0dad3b5..c937b8f5e 100644
--- a/axiom/test/xpath/Makefile.am
+++ b/axiom/test/xpath/Makefile.am
@@ -21,6 +21,11 @@ TESTS = test_xpath test_xpath_streaming
noinst_PROGRAMS = test_xpath test_xpath_streaming
check_PROGRAMS = test_xpath test_xpath_streaming
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
test_xpath_SOURCES = test_xpath.cc
test_xpath_streaming_SOURCES = test_xpath_streaming.cc
diff --git a/configure.ac b/configure.ac
index 3376786b2..223fc0303 100644
--- a/configure.ac
+++ b/configure.ac
@@ -494,6 +494,7 @@ AC_ARG_ENABLE(asan, [ --enable-asan
AC_MSG_RESULT(no)
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"
+ enable_asan=no
;;
*)
AC_MSG_RESULT(yes)
@@ -502,13 +503,42 @@ AC_ARG_ENABLE(asan, [ --enable-asan
CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-omit-frame-pointer"
dnl LDFLAGS must include -fsanitize=address for executables to link correctly
LDFLAGS="$LDFLAGS -fsanitize=address"
+ enable_asan=yes
;;
esac ],[
AC_MSG_RESULT(no)
CFLAGS="$CFLAGS"
- CPPFLAGS="$CPPFLAGS"]
+ CPPFLAGS="$CPPFLAGS"
+ enable_asan=no]
)
+dnl Create automake conditional for ASAN
+AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
+
+dnl Detect ASAN library path for test preloading (only when ASAN enabled)
+dnl This is needed because libtool-wrapped tests need LD_PRELOAD to work with ASAN
+ASAN_PRELOAD=""
+if test "x$enable_asan" = "xyes"; then
+ AC_MSG_CHECKING([for ASAN library path])
+ dnl Try common locations for libasan
+ for asan_path in /lib/x86_64-linux-gnu/libasan.so.8 \
+ /lib/x86_64-linux-gnu/libasan.so.6 \
+ /lib64/libasan.so.8 \
+ /lib64/libasan.so.6 \
+ /usr/lib/libasan.so; do
+ if test -f "$asan_path"; then
+ ASAN_PRELOAD="$asan_path"
+ break
+ fi
+ done
+ if test -n "$ASAN_PRELOAD"; then
+ AC_MSG_RESULT([$ASAN_PRELOAD])
+ else
+ AC_MSG_RESULT([not found - tests may fail])
+ fi
+fi
+AC_SUBST([ASAN_PRELOAD])
+
AC_MSG_CHECKING(whether to enable multi threading)
AC_ARG_ENABLE(multi-thread, [ --enable-multi-thread
diff --git a/guththila/configure.ac b/guththila/configure.ac
index a276ffbc6..0a9ff739d 100644
--- a/guththila/configure.ac
+++ b/guththila/configure.ac
@@ -122,21 +122,50 @@ AC_ARG_ENABLE(asan, [ --enable-asan
[ case "${enableval}" in
no)
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"
;;
*)
AC_MSG_RESULT(yes)
+ enable_asan=yes
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
CPPFLAGS="$CPPFLAGS -fsanitize=address -fno-omit-frame-pointer"
CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-omit-frame-pointer"
+ LDFLAGS="$LDFLAGS -fsanitize=address"
;;
esac ],[
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"]
)
+dnl Create automake conditional for ASAN (used by test Makefile.am for LD_PRELOAD)
+AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
+
+dnl Detect ASAN library path for test preloading (libtool-wrapped tests need this)
+ASAN_PRELOAD=""
+if test "x$enable_asan" = "xyes"; then
+ AC_MSG_CHECKING([for ASAN library path])
+ for asan_path in /lib/x86_64-linux-gnu/libasan.so.8 \
+ /lib/x86_64-linux-gnu/libasan.so.6 \
+ /lib64/libasan.so.8 \
+ /lib64/libasan.so.6 \
+ /usr/lib/libasan.so; do
+ if test -f "$asan_path"; then
+ ASAN_PRELOAD="$asan_path"
+ break
+ fi
+ done
+ if test -n "$ASAN_PRELOAD"; then
+ AC_MSG_RESULT([$ASAN_PRELOAD])
+ else
+ AC_MSG_RESULT([not found - tests may fail with libtool wrappers])
+ fi
+fi
+AC_SUBST([ASAN_PRELOAD])
+
AC_MSG_CHECKING(whether to use the Google test framework)
AC_ARG_WITH(gtest,
diff --git a/guththila/tests/Makefile.am b/guththila/tests/Makefile.am
index 4f6269b8c..a55651787 100644
--- a/guththila/tests/Makefile.am
+++ b/guththila/tests/Makefile.am
@@ -21,6 +21,11 @@ TESTS = test_guththila test_attribute test_stack test_token
noinst_PROGRAMS = test_guththila test_attribute test_stack test_token
check_PROGRAMS = test_guththila test_attribute test_stack test_token
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
# Set up test resources before running tests
check-local:
$(MKDIR_P) $(builddir)/resources/om
diff --git a/neethi/configure.ac b/neethi/configure.ac
index e1a3715a8..f4a294ff0 100644
--- a/neethi/configure.ac
+++ b/neethi/configure.ac
@@ -154,11 +154,13 @@ AC_ARG_ENABLE(asan, [ --enable-asan
[ case "${enableval}" in
no)
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"
;;
*)
AC_MSG_RESULT(yes)
+ enable_asan=yes
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
CPPFLAGS="$CPPFLAGS -fsanitize=address -fno-omit-frame-pointer"
CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-omit-frame-pointer"
@@ -167,10 +169,36 @@ AC_ARG_ENABLE(asan, [ --enable-asan
;;
esac ],[
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"]
)
+dnl Create automake conditional for ASAN (used by test Makefile.am for LD_PRELOAD)
+AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
+
+dnl Detect ASAN library path for test preloading (libtool-wrapped tests need this)
+ASAN_PRELOAD=""
+if test "x$enable_asan" = "xyes"; then
+ AC_MSG_CHECKING([for ASAN library path])
+ for asan_path in /lib/x86_64-linux-gnu/libasan.so.8 \
+ /lib/x86_64-linux-gnu/libasan.so.6 \
+ /lib64/libasan.so.8 \
+ /lib64/libasan.so.6 \
+ /usr/lib/libasan.so; do
+ if test -f "$asan_path"; then
+ ASAN_PRELOAD="$asan_path"
+ break
+ fi
+ done
+ if test -n "$ASAN_PRELOAD"; then
+ AC_MSG_RESULT([$ASAN_PRELOAD])
+ else
+ AC_MSG_RESULT([not found - tests may fail with libtool wrappers])
+ fi
+fi
+AC_SUBST([ASAN_PRELOAD])
+
AC_MSG_CHECKING(whether to use the Google test framework)
AC_ARG_WITH(gtest,
diff --git a/neethi/test/Makefile.am b/neethi/test/Makefile.am
index e6c7ee34d..10d191cdc 100644
--- a/neethi/test/Makefile.am
+++ b/neethi/test/Makefile.am
@@ -21,6 +21,11 @@ TESTS = test
noinst_PROGRAMS = test
check_PROGRAMS = test
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
test_SOURCES = test.cc
AM_CPPFLAGS = -I$(top_srcdir)/include \
diff --git a/src/core/transport/h2/test/Makefile.am b/src/core/transport/h2/test/Makefile.am
index f0fc6ae34..f31af2872 100644
--- a/src/core/transport/h2/test/Makefile.am
+++ b/src/core/transport/h2/test/Makefile.am
@@ -23,6 +23,11 @@ check_PROGRAMS = h2_json_integration_test h2_performance_benchmark_test
noinst_PROGRAMS = h2_json_integration_test h2_performance_benchmark_test
TESTS = h2_json_integration_test h2_performance_benchmark_test
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
# HTTP/2 JSON Integration Test
h2_json_integration_test_SOURCES = h2_json_integration_test.c \
large_json_payload_generator.c
diff --git a/test/core/addr/Makefile.am b/test/core/addr/Makefile.am
index a3f5c35e1..803d39aa5 100644
--- a/test/core/addr/Makefile.am
+++ b/test/core/addr/Makefile.am
@@ -17,6 +17,12 @@ if GTEST_AVAILABLE
TESTS = test_addr
check_PROGRAMS = test_addr
noinst_PROGRAMS = test_addr
+
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
SUBDIRS =
AM_CFLAGS = -g
test_addr_SOURCES = test_addr.cc
diff --git a/test/core/clientapi/Makefile.am b/test/core/clientapi/Makefile.am
index a0c887c4b..afc2ba380 100644
--- a/test/core/clientapi/Makefile.am
+++ b/test/core/clientapi/Makefile.am
@@ -17,6 +17,12 @@ if GTEST_AVAILABLE
TESTS = test_client test_svc_client_handler_count test_clientapi test_axis2c_1355
noinst_PROGRAMS = test_client test_clientapi test_svc_client_handler_count test_axis2c_1355
check_PROGRAMS = test_client test_clientapi test_svc_client_handler_count test_axis2c_1355
+
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
SUBDIRS =
AM_CFLAGS = -g -pthread
test_client_SOURCES = test_client.cc
diff --git a/test/core/context/Makefile.am b/test/core/context/Makefile.am
index 312ed1812..3de16cfb1 100644
--- a/test/core/context/Makefile.am
+++ b/test/core/context/Makefile.am
@@ -17,6 +17,12 @@ if GTEST_AVAILABLE
TESTS = test_context
check_PROGRAMS = test_context
noinst_PROGRAMS = test_context
+
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
SUBDIRS =
AM_CFLAGS = -g
test_context_SOURCES = test_context.cc
diff --git a/test/core/deployment/Makefile.am b/test/core/deployment/Makefile.am
index 6dd495c7d..1caa127ba 100644
--- a/test/core/deployment/Makefile.am
+++ b/test/core/deployment/Makefile.am
@@ -16,6 +16,12 @@
if GTEST_AVAILABLE
TESTS = test_deployment
noinst_PROGRAMS = test_deployment
+
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
SUBDIRS =
AM_CFLAGS = $(CFLAGS) -g
test_deployment_SOURCES = test_deployment.cc
diff --git a/test/core/description/Makefile.am b/test/core/description/Makefile.am
index a5822aa28..d87df4d50 100644
--- a/test/core/description/Makefile.am
+++ b/test/core/description/Makefile.am
@@ -16,6 +16,12 @@
if GTEST_AVAILABLE
TESTS = test_description
noinst_PROGRAMS = test_description
+
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
SUBDIRS =
AM_CFLAGS = -g -O2
test_description_SOURCES = test_description.cc
diff --git a/test/core/engine/Makefile.am b/test/core/engine/Makefile.am
index 4058fe7c5..334a62fca 100644
--- a/test/core/engine/Makefile.am
+++ b/test/core/engine/Makefile.am
@@ -27,6 +27,11 @@ check_PROGRAMS = test_engine test_phase
noinst_PROGRAMS = test_engine test_phase
endif
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
SUBDIRS =
AM_CFLAGS = -g
test_engine_SOURCES = test_engine.cc
diff --git a/test/core/transport/http/Makefile.am b/test/core/transport/http/Makefile.am
index 1b8035e26..405b4a0d3 100644
--- a/test/core/transport/http/Makefile.am
+++ b/test/core/transport/http/Makefile.am
@@ -31,6 +31,11 @@ check_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532
noinst_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532
TESTS += test_http_transport test_axis2c_1480 test_axis2c_1532
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
+
AM_CFLAGS = -g -pthread
test_http_transport_SOURCES = test_http_transport.cc
diff --git a/util/configure.ac b/util/configure.ac
index fd52179b4..4d01a928b 100644
--- a/util/configure.ac
+++ b/util/configure.ac
@@ -264,11 +264,13 @@ AC_ARG_ENABLE(asan, [ --enable-asan
[ case "${enableval}" in
no)
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"
;;
*)
AC_MSG_RESULT(yes)
+ enable_asan=yes
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
CPPFLAGS="$CPPFLAGS -fsanitize=address -fno-omit-frame-pointer"
CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-omit-frame-pointer"
@@ -277,10 +279,36 @@ AC_ARG_ENABLE(asan, [ --enable-asan
;;
esac ],[
AC_MSG_RESULT(no)
+ enable_asan=no
CFLAGS="$CFLAGS"
CPPFLAGS="$CPPFLAGS"]
)
+dnl Create automake conditional for ASAN (used by test Makefile.am for LD_PRELOAD)
+AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
+
+dnl Detect ASAN library path for test preloading (libtool-wrapped tests need this)
+ASAN_PRELOAD=""
+if test "x$enable_asan" = "xyes"; then
+ AC_MSG_CHECKING([for ASAN library path])
+ for asan_path in /lib/x86_64-linux-gnu/libasan.so.8 \
+ /lib/x86_64-linux-gnu/libasan.so.6 \
+ /lib64/libasan.so.8 \
+ /lib64/libasan.so.6 \
+ /usr/lib/libasan.so; do
+ if test -f "$asan_path"; then
+ ASAN_PRELOAD="$asan_path"
+ break
+ fi
+ done
+ if test -n "$ASAN_PRELOAD"; then
+ AC_MSG_RESULT([$ASAN_PRELOAD])
+ else
+ AC_MSG_RESULT([not found - tests may fail with libtool wrappers])
+ fi
+fi
+AC_SUBST([ASAN_PRELOAD])
+
AC_MSG_CHECKING(whether to use use the Google test framework)
AC_ARG_WITH(gtest,
diff --git a/util/test/utils/Makefile.am b/util/test/utils/Makefile.am
index 380c6aa98..2cc54e2c2 100644
--- a/util/test/utils/Makefile.am
+++ b/util/test/utils/Makefile.am
@@ -15,6 +15,11 @@
TESTS = utils_test
check_PROGRAMS = utils_test
noinst_PROGRAMS = utils_test
+
+# ASAN preload for libtool-wrapped test execution
+if ENABLE_ASAN
+TESTS_ENVIRONMENT = LD_PRELOAD=$(ASAN_PRELOAD)
+endif
utils_test_SOURCES = utils_test.cc
utils_test_LDADD = \
(axis-axis2-c-core) 02/05: Remove broken and unused axutil_strtol/axutil_strtoul functions (AXIS2C-1508)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit e2d96d8879e916c8817a84fe501c125eab14e408
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Fri Jan 23 09:45:46 2026 -1000
Remove broken and unused axutil_strtol/axutil_strtoul functions (AXIS2C-1508)
These functions were severely broken:
- Did not handle negative numbers (returned 0 for "-123")
- Did not handle positive sign or leading whitespace
- Completely ignored the base parameter
- Never matched standard strtol/strtoul behavior
More importantly, they were dead code - never actually used anywhere
in the codebase. All actual code uses the standard library strtol()
directly (22 call sites in samples/ and util/).
Removed:
- axutil_strtol() function from util/src/types.c
- axutil_strtoul() function from util/src/types.c
- AXIS2_STRTOL macro from util/include/axutil_types.h
- AXIS2_STRTOUL macro from util/include/axutil_types.h
The remaining axutil_atoi() and axutil_atol() functions are kept as
they follow consistent (if limited) behavior and are actually used.
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
util/include/axutil_types.h | 17 -----------------
util/src/types.c | 42 ------------------------------------------
2 files changed, 59 deletions(-)
diff --git a/util/include/axutil_types.h b/util/include/axutil_types.h
index d6df33904..5b8c3169a 100644
--- a/util/include/axutil_types.h
+++ b/util/include/axutil_types.h
@@ -41,23 +41,6 @@ extern "C"
#define AXIS2_ATOI(s) axutil_atoi(s)
- AXIS2_EXTERN uint64_t AXIS2_CALL
- axutil_strtoul(
- const char *nptr,
- char **endptr,
- int base);
-
-#define AXIS2_STRTOUL(s, e, b) axutil_strtoul(s, e, b)
-
- AXIS2_EXTERN int64_t AXIS2_CALL
- axutil_strtol(
- const char *nptr,
- char **endptr,
- int base);
-
-#define AXIS2_STRTOL(s, e, b) axutil_strtol(s, e, b)
-
-
AXIS2_EXTERN int64_t AXIS2_CALL
axutil_atol(
const char *s);
diff --git a/util/src/types.c b/util/src/types.c
index a47cc67bf..d1db26613 100644
--- a/util/src/types.c
+++ b/util/src/types.c
@@ -45,45 +45,3 @@ axutil_atol(
}
return n;
}
-
-AXIS2_EXTERN uint64_t AXIS2_CALL
-axutil_strtoul(
- const char *s,
- char **endptr,
- int base)
-{
- int i;
- uint64_t n;
-
- n = 0;
- for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
- {
- n = 10 * n + (s[i] - '0');
- }
- if(endptr != NULL)
- {
- *endptr = (char *)(s + i);
- }
- return n;
-}
-
-AXIS2_EXTERN int64_t AXIS2_CALL
-axutil_strtol(
- const char *s,
- char **endptr,
- int base)
-{
- int i;
- int64_t n;
-
- n = 0;
- for(i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
- {
- n = 10 * n + (s[i] - '0');
- }
- if(endptr != NULL)
- {
- *endptr = (char *)(s + i);
- }
- return n;
-}
(axis-axis2-c-core) 01/05: Fix last POST parameter skipped when it has no value (AXIS2C-1532)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 055eb8d5b44b290ed3cd00ea593d49a6282e66ed
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Fri Jan 23 09:10:30 2026 -1000
Fix last POST parameter skipped when it has no value (AXIS2C-1532)
The bug was in axis2_http_transport_utils_get_request_params() which
parsed URL query string parameters. After the parsing loop, there was
a check that required the parameter value to be non-empty:
if(tmp_name && AXIS2_ESC_NULL != *tmp2)
This caused parameters with empty values to be skipped. For example,
a query string like "param1=value1¶m2=" would only include param1
in the result hash, silently dropping param2.
The fix removes the *tmp2 != '\0' check, allowing empty values to be
stored. This matches the behavior described in the JIRA issue and is
consistent with how other web frameworks handle empty query parameters.
Added comprehensive test suite covering:
- Normal parameters with values
- Single parameter with empty value
- Last parameter with empty value (the main bug)
- Middle parameter with empty value
- All parameters with empty values
- No query string / empty query string
- URL-encoded values
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
.../transport/http/util/http_transport_utils.c | 6 +-
test/core/transport/http/Makefile.am | 35 ++-
test/core/transport/http/test_axis2c_1532.cc | 252 +++++++++++++++++++++
3 files changed, 289 insertions(+), 4 deletions(-)
diff --git a/src/core/transport/http/util/http_transport_utils.c b/src/core/transport/http/util/http_transport_utils.c
index a92c6e903..595b0c297 100644
--- a/src/core/transport/http/util/http_transport_utils.c
+++ b/src/core/transport/http/util/http_transport_utils.c
@@ -1775,7 +1775,11 @@ axis2_http_transport_utils_get_request_params(
tmp_value = NULL;
}
}
- if(tmp_name && AXIS2_ESC_NULL != *tmp2)
+ /* AXIS2C-1532: Handle the last parameter after the loop ends.
+ * Previously this required *tmp2 != '\0', which skipped parameters with
+ * empty values (e.g., "param1=value1¶m2=" would skip param2).
+ * Now we allow empty values - axutil_strdup of an empty string is valid. */
+ if(tmp_name)
{
if(!ret)
{
diff --git a/test/core/transport/http/Makefile.am b/test/core/transport/http/Makefile.am
index 7239682eb..1b8035e26 100644
--- a/test/core/transport/http/Makefile.am
+++ b/test/core/transport/http/Makefile.am
@@ -27,9 +27,9 @@ TESTS =
# HTTP/2 mode doesn't build the receiver/sender libraries that this test needs
if GTEST_AVAILABLE
if !WITH_NGHTTP2
-check_PROGRAMS += test_http_transport test_axis2c_1480
-noinst_PROGRAMS += test_http_transport test_axis2c_1480
-TESTS += test_http_transport test_axis2c_1480
+check_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532
+noinst_PROGRAMS += test_http_transport test_axis2c_1480 test_axis2c_1532
+TESTS += test_http_transport test_axis2c_1480 test_axis2c_1532
AM_CFLAGS = -g -pthread
test_http_transport_SOURCES = test_http_transport.cc
@@ -78,6 +78,35 @@ test_axis2c_1480_CPPFLAGS = \
-I ../../../../axiom/include \
-I $(GTEST_DIR)/include
+# AXIS2C-1532: Empty parameter value tests
+test_axis2c_1532_SOURCES = test_axis2c_1532.cc
+
+test_axis2c_1532_LDADD = \
+ $(LDFLAGS) \
+ ../../../../util/src/libaxutil.la \
+ ../../../../axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/neethi/src/libneethi.la \
+ ../../../../axiom/src/parser/$(WRAPPER_DIR)/libaxis2_parser.la \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/receiver/libaxis2_http_receiver.la \
+ $(top_builddir)/src/core/transport/http/sender/libaxis2_http_sender.la \
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
+ $(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
+ $(top_builddir)/$(GTEST)/libgtest.a \
+ $(top_builddir)/$(GTEST)/libgtest_main.a \
+ -lpthread
+
+# Ensure all shared libraries are linked even if not directly referenced by test code.
+# The test only calls axis2_http_transport_utils_get_request_params() which is in
+# libaxis2_http_util, but that library needs symbols from libaxis2_engine.
+test_axis2c_1532_LDFLAGS = -Wl,--no-as-needed
+
+test_axis2c_1532_CPPFLAGS = \
+ -I$(top_builddir)/include \
+ -I ../../../../util/include \
+ -I ../../../../axiom/include \
+ -I $(GTEST_DIR)/include
+
# Add JSON support conditionally
if AXIS2_JSON_ENABLED
test_http_transport_LDADD += $(JSON_LIBS)
diff --git a/test/core/transport/http/test_axis2c_1532.cc b/test/core/transport/http/test_axis2c_1532.cc
new file mode 100644
index 000000000..a6c0018b1
--- /dev/null
+++ b/test/core/transport/http/test_axis2c_1532.cc
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test for AXIS2C-1532: Last POST parameter is skipped when it has no value
+ *
+ * This test verifies that URL query string parameters with empty values
+ * are correctly parsed and included in the parameter hash.
+ *
+ * The bug was that a query string like "param1=value1¶m2=" would
+ * skip param2 because the code required the value to be non-empty.
+ */
+
+#include <gtest/gtest.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <axutil_env.h>
+#include <axutil_allocator.h>
+#include <axutil_error_default.h>
+#include <axutil_log_default.h>
+#include <axutil_hash.h>
+#include <axis2_http_transport_utils.h>
+
+class TestAxis2C1532 : public ::testing::Test
+{
+protected:
+ void SetUp() override
+ {
+ m_allocator = axutil_allocator_init(NULL);
+ ASSERT_NE(m_allocator, nullptr);
+
+ m_error = axutil_error_create(m_allocator);
+ ASSERT_NE(m_error, nullptr);
+
+ m_log = axutil_log_create(m_allocator, NULL, NULL);
+ ASSERT_NE(m_log, nullptr);
+
+ m_env = axutil_env_create_with_error_log(m_allocator, m_error, m_log);
+ ASSERT_NE(m_env, nullptr);
+ }
+
+ void TearDown() override
+ {
+ if (m_env)
+ {
+ axutil_env_free(m_env);
+ m_env = NULL;
+ }
+ }
+
+ /**
+ * Helper to get a value from the param hash and compare
+ */
+ void AssertParamValue(axutil_hash_t *params, const char *key, const char *expected_value)
+ {
+ ASSERT_NE(params, nullptr) << "params hash is NULL";
+ void *value = axutil_hash_get(params, key, AXIS2_HASH_KEY_STRING);
+ if (expected_value == NULL)
+ {
+ EXPECT_EQ(value, nullptr) << "Expected param '" << key << "' to be absent";
+ }
+ else
+ {
+ ASSERT_NE(value, nullptr) << "Param '" << key << "' not found in hash";
+ EXPECT_STREQ((char *)value, expected_value)
+ << "Param '" << key << "' has wrong value";
+ }
+ }
+
+ /**
+ * Helper to free param hash and its contents
+ */
+ void FreeParamHash(axutil_hash_t *params)
+ {
+ if (params)
+ {
+ axutil_hash_index_t *hi;
+ for (hi = axutil_hash_first(params, m_env); hi; hi = axutil_hash_next(m_env, hi))
+ {
+ const void *key;
+ void *value;
+ axutil_hash_this(hi, &key, NULL, &value);
+ if (value)
+ {
+ AXIS2_FREE(m_env->allocator, value);
+ }
+ }
+ axutil_hash_free(params, m_env);
+ }
+ }
+
+ axutil_allocator_t *m_allocator = NULL;
+ axutil_env_t *m_env = NULL;
+ axutil_error_t *m_error = NULL;
+ axutil_log_t *m_log = NULL;
+};
+
+/**
+ * Test normal parameters with values - baseline test
+ */
+TEST_F(TestAxis2C1532, test_normal_params_with_values)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method?param1=value1¶m2=value2");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ ASSERT_NE(params, nullptr);
+ AssertParamValue(params, "param1", "value1");
+ AssertParamValue(params, "param2", "value2");
+
+ FreeParamHash(params);
+ AXIS2_FREE(m_env->allocator, uri);
+}
+
+/**
+ * Test single parameter with empty value
+ */
+TEST_F(TestAxis2C1532, test_single_param_empty_value)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method?param1=");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ ASSERT_NE(params, nullptr) << "Should return hash even for empty value";
+ AssertParamValue(params, "param1", "");
+
+ FreeParamHash(params);
+ AXIS2_FREE(m_env->allocator, uri);
+}
+
+/**
+ * AXIS2C-1532: Last parameter with empty value should NOT be skipped
+ * This is the main regression test for the bug.
+ */
+TEST_F(TestAxis2C1532, test_last_param_empty_value)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method?param1=value1¶m2=");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ ASSERT_NE(params, nullptr);
+ AssertParamValue(params, "param1", "value1");
+ /* AXIS2C-1532: This used to fail - param2 was skipped */
+ AssertParamValue(params, "param2", "");
+
+ FreeParamHash(params);
+ AXIS2_FREE(m_env->allocator, uri);
+}
+
+/**
+ * Test multiple parameters where middle one has empty value
+ */
+TEST_F(TestAxis2C1532, test_middle_param_empty_value)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method?param1=value1¶m2=¶m3=value3");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ ASSERT_NE(params, nullptr);
+ AssertParamValue(params, "param1", "value1");
+ AssertParamValue(params, "param2", "");
+ AssertParamValue(params, "param3", "value3");
+
+ FreeParamHash(params);
+ AXIS2_FREE(m_env->allocator, uri);
+}
+
+/**
+ * Test all parameters with empty values
+ */
+TEST_F(TestAxis2C1532, test_all_params_empty_values)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method?param1=¶m2=¶m3=");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ ASSERT_NE(params, nullptr);
+ AssertParamValue(params, "param1", "");
+ AssertParamValue(params, "param2", "");
+ AssertParamValue(params, "param3", "");
+
+ FreeParamHash(params);
+ AXIS2_FREE(m_env->allocator, uri);
+}
+
+/**
+ * Test no query string - should return NULL
+ */
+TEST_F(TestAxis2C1532, test_no_query_string)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ EXPECT_EQ(params, nullptr) << "Should return NULL when no query string";
+
+ AXIS2_FREE(m_env->allocator, uri);
+}
+
+/**
+ * Test empty query string (just ?) - should return NULL
+ */
+TEST_F(TestAxis2C1532, test_empty_query_string)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method?");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ EXPECT_EQ(params, nullptr) << "Should return NULL for empty query string";
+
+ AXIS2_FREE(m_env->allocator, uri);
+}
+
+/**
+ * Test URL-encoded values
+ */
+TEST_F(TestAxis2C1532, test_url_encoded_values)
+{
+ char *uri = (char *)axutil_strdup(m_env,
+ "/service/method?param1=hello%20world¶m2=foo%26bar");
+
+ axutil_hash_t *params = axis2_http_transport_utils_get_request_params(m_env, uri);
+
+ ASSERT_NE(params, nullptr);
+ AssertParamValue(params, "param1", "hello world");
+ AssertParamValue(params, "param2", "foo&bar");
+
+ FreeParamHash(params);
+ AXIS2_FREE(m_env->allocator, uri);
+}