|
From: Thien H. <thi...@en...> - 2025-12-01 08:08:44
|
imm import does not handle parse empty tag.
This commit just handle parse empty tag to SaImmAttrValuesT_2.
---
src/imm/immloadd/imm_loader.cc | 3 ++-
src/imm/tools/imm_import.cc | 32 ++++++++++++++++++--------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/imm/immloadd/imm_loader.cc b/src/imm/immloadd/imm_loader.cc
index e0d7c6caa..4af988642 100644
--- a/src/imm/immloadd/imm_loader.cc
+++ b/src/imm/immloadd/imm_loader.cc
@@ -1767,7 +1767,8 @@ void addObjectAttributeDefinition(
SaImmAttrValuesT_2 attrValues;
int i;
size_t len;
- bool null_value = attrValueBuffers->empty();
+ bool null_value =
+ attrValueBuffers->empty() || strlen(*(attrValueBuffers->begin())) == 0;
TRACE_ENTER2("attrValueBuffers size:%u",
(unsigned int)attrValueBuffers->size());
diff --git a/src/imm/tools/imm_import.cc b/src/imm/tools/imm_import.cc
index 4b66b6b1b..1823e48ad 100644
--- a/src/imm/tools/imm_import.cc
+++ b/src/imm/tools/imm_import.cc
@@ -136,6 +136,7 @@ typedef struct ParserStateStruct {
SaImmAttrFlagsT attrFlags;
SaUint32T attrNtfId;
char *attrDefaultValueBuffer;
+ bool is_null_value;
int attrValueTypeSet;
int attrNtfIdSet;
@@ -825,6 +826,7 @@ done:
for (it = state->attrValues.begin(); it != state->attrValues.end(); ++it) {
free(it->attrName);
+ if (!it->attrValues || it->attrValuesNumber == 0) continue;
for (i = 0; it->attrValues[i]; i++) {
free_attr_value(it->attrValueType, it->attrValues[i]);
}
@@ -1495,6 +1497,13 @@ static void startElementHandler(void *userData, const xmlChar *name,
state->state[state->depth] = VALUE;
state->valueContinue = 0;
state->isBase64Encoded = isBase64Encoded(attrs);
+ state->is_null_value = false;
+ if (attrs) {
+ char* null_value = getAttributeValue("xsi:nil", attrs);
+ if (null_value && std::string{null_value} == "true") {
+ state->is_null_value = true;
+ }
+ }
/* <category> */
} else if (strcmp((const char *)name, "category") == 0) {
state->state[state->depth] = CATEGORY;
@@ -1551,7 +1560,7 @@ static void endElementHandler(void *userData, const xmlChar *name) {
/* </value> */
if (strcmp((const char *)name, "value") == 0) {
- if (state->attrValueBuffers.empty()) {
+ if (state->attrValueBuffers.empty() && !state->is_null_value) {
char *str = (char *)malloc(1);
str[0] = '\0';
@@ -2144,14 +2153,6 @@ static void addObjectAttributeDefinition(ParserState *state) {
return;
}
- /* The value array can not be empty */
- if (state->attrValueBuffers.empty()) {
- LOG_ER("The value array can not be empty");
- stopParser(state);
- state->parsingStatus = 1;
- return;
- }
-
/* The object class must be set */
if (!state->objectClass) {
LOG_ER("The object class must be set");
@@ -2185,17 +2186,20 @@ static void addObjectAttributeDefinition(ParserState *state) {
TRACE_8("addObjectAttributeDefinition %s, %s, %d", state->className,
state->attrName, attrValues.attrValueType);
+ bool null_value = state->attrValueBuffers.empty() ||
+ strlen(*state->attrValueBuffers.begin()) == 0;
+
/* For each value, convert from char* to SaImmAttrValuesT_2 and
store an array pointing to all in attrValues */
- attrValues.attrValuesNumber = state->attrValueBuffers.size();
- attrValues.attrValues = (SaImmAttrValueT *)calloc(
+ attrValues.attrValuesNumber = null_value ? 0 : state->attrValueBuffers.size();
+ attrValues.attrValues = null_value ? nullptr : (SaImmAttrValueT *)calloc(
1, sizeof(SaImmAttrValuesT_2) * attrValues.attrValuesNumber + 1);
- attrValues.attrValues[attrValues.attrValuesNumber] = NULL;
+ if (!null_value) attrValues.attrValues[attrValues.attrValuesNumber] = NULL;
it = state->attrValueBuffers.begin();
i = 0;
- while (it != state->attrValueBuffers.end()) {
+ while (!null_value && it != state->attrValueBuffers.end()) {
TRACE_8("NAME: %s", state->attrName);
if (charsToValueHelper(&attrValues.attrValues[i], attrValues.attrValueType,
@@ -2224,7 +2228,7 @@ static void addObjectAttributeDefinition(ParserState *state) {
/* Add attrValues to the list */
state->attrValues.push_front(attrValues);
}
- } else {
+ } else if (!null_value) {
i = 0;
while (attrValues.attrValues[i]) {
if (attrValues.attrValueType == SA_IMM_ATTR_SASTRINGT)
--
2.34.1
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Any opinions expressed are mine and do not necessarily represent the opinions of the Company. Emails are susceptible to interference. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is strictly prohibited and may be unlawful. If you have received this message in error, do not open any attachments but please notify the Endava Service Desk on (+44 (0)870 423 0187), and delete this message from your system. The sender accepts no responsibility for information, errors or omissions in this email, or for its use or misuse, or for any act committed or omitted in connection with this communication. If in doubt, please verify the authenticity of the contents with the sender. Please rely on your own virus checkers as no responsibility is taken by the sender for any damage rising out of any bug or virus infection.
Endava plc is a company registered in England under company number 5722669 whose registered office is at 125 Old Broad Street, London, EC2N 1AR, United Kingdom. Endava plc is the Endava group holding company and does not provide any services to clients. Each of Endava plc and its subsidiaries is a separate legal entity and has no liability for another such entity's acts or omissions.
|