[
https://issues.apache.org/jira/browse/AXIS2C-1492?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Lazarski resolved AXIS2C-1492.
-------------------------------------
Fix Version/s: 2.0.0
Resolution: Fixed
The issue: xsd:unsignedInt values above 2147483647 (INT_MAX) were
incorrectly truncated because the generated code used atoi() which
returns signed int. Values like 3000000000 would overflow to negative
numbers (-1294967296).
The fix adds proper XSD integer type detection and C type mapping:
Type detection helpers:
- is_unsigned_integer_type(): Detects unsignedInt, unsignedLong,
unsignedShort, unsignedByte, positiveInteger, nonNegativeInteger
- is_64bit_integer_type(): Detects long, unsignedLong, integer types
- is_integer_type(): Detects all integer types (for free function)
C type mapping:
- xsd:unsignedInt -> unsigned int
- xsd:unsignedLong -> uint64_t
- xsd:unsignedShort -> unsigned int
- xsd:unsignedByte -> unsigned int
- xsd:positiveInteger -> uint64_t
- xsd:nonNegativeInteger -> uint64_t
Conversion functions:
- Unsigned 32-bit types: strtoul(text_value, NULL, 10)
- Unsigned 64-bit types: strtoull(text_value, NULL, 10)
- Signed types: atoi() for 32-bit, strtoll() for 64-bit
Format specifiers:
- Unsigned 32-bit: %u
- Unsigned 64-bit: %llu
- Signed 32-bit: %d
- Signed 64-bit: %lld
Also fixes the _free function to not call AXIS2_FREE on primitive
integer types (they're stack values in the struct, not pointers).
> maximum value of xsd:unsignedInt cannot exceed maximum value of signed
> integer (2147483647)
> -------------------------------------------------------------------------------------------
>
> Key: AXIS2C-1492
> URL: https://issues.apache.org/jira/browse/AXIS2C-1492
> Project: Axis2-C
> Issue Type: Bug
> Components: code generation
> Affects Versions: 1.6.0
> Reporter: Maria Indeeva
> Priority: Major
> Fix For: 2.0.0
>
>
> Deserialize functionality for xsd:unsignedInt values is done via atoi()
> function. Here is an example of the generated code for unsignedInt element:
> text_value = axiom_element_get_text(current_element, env, current_node);
> if(text_value != NULL)
> {
> status = adb_clientClass_set_priority(_clientClass, env,
> atoi(text_value));
> }
> Here is how that element is defined in XSD file:
> <xsd:element name="priority" type="xsd:unsignedInt">
> ...
> </xsd:element
> Unfortunately atoi is returning int (signed integer) and as a result whenever
> the value for that unsignedInt element is set to be large than the maximum
> value for SIGNED integer (larger than 2147483647) it is decreased to
> 2147483647, while the maximum value for unsignedInt should be 4294967295.
> Once the atoi() in generated code is replaced with strtoul() the problem is
> gone.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]