Skip to content

Commit dc44cfa

Browse files
committed
configuration.c: bugfix:optional params parsing
- fixed optional configuration params to being parsed as optional - improved error messages for memory allocation error
1 parent 507749e commit dc44cfa

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

extra_plugins/output/unirec/configuration.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ static const struct fds_xml_args args_params[] = {
8080
FDS_OPTS_ROOT("params"),
8181
FDS_OPTS_ELEM(NODE_TRAP_IFC_TYPE, "trapIfcType", FDS_OPTS_T_STRING, 0),
8282
FDS_OPTS_ELEM(NODE_TRAP_IFC_SOCKET, "trapIfcSocket", FDS_OPTS_T_STRING, 0),
83-
FDS_OPTS_ELEM(NODE_TRAP_IFC_TIMEOUT, "trapIfcTimeout", FDS_OPTS_T_STRING, 0),
84-
FDS_OPTS_ELEM(NODE_TRAP_IFC_FLUSH_TIMEOUT, "trapIfcFlushTimeout", FDS_OPTS_T_STRING, 0),
85-
FDS_OPTS_ELEM(NODE_TRAP_IFC_BUFFER_SWITCH, "trapIfcBufferSwitch", FDS_OPTS_T_STRING, 0),
83+
FDS_OPTS_ELEM(NODE_TRAP_IFC_TIMEOUT, "trapIfcTimeout", FDS_OPTS_T_STRING, FDS_OPTS_P_OPT),
84+
FDS_OPTS_ELEM(NODE_TRAP_IFC_FLUSH_TIMEOUT, "trapIfcFlushTimeout", FDS_OPTS_T_STRING, FDS_OPTS_P_OPT),
85+
FDS_OPTS_ELEM(NODE_TRAP_IFC_BUFFER_SWITCH, "trapIfcBufferSwitch", FDS_OPTS_T_STRING, FDS_OPTS_P_OPT),
8686
FDS_OPTS_ELEM(NODE_UNIREC_FORMAT, "UniRecFormat", FDS_OPTS_T_STRING, 0),
8787
FDS_OPTS_END
8888
};
@@ -148,39 +148,39 @@ configuration_parse_root(ipx_ctx_t *ctx, fds_xml_ctx_t *root, struct conf_params
148148
assert(content->type == FDS_OPTS_T_STRING);
149149
cnf->trap_ifc_socket = strdup(content->ptr_string);
150150
if(cnf->trap_ifc_socket == NULL) {
151-
IPX_CTX_ERROR(ctx, "Unable to allocate memory for trap interface socket.");
151+
IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
152152
return IPX_ERR_NOMEM;
153153
}
154154
break;
155155
case NODE_TRAP_IFC_TIMEOUT:
156156
assert(content->type == FDS_OPTS_T_STRING);
157157
cnf->trap_ifc_timeout = strdup(content->ptr_string);
158158
if(cnf->trap_ifc_timeout == NULL) {
159-
IPX_CTX_ERROR(ctx, "Unable to allocate memory for trap interface timeout.");
159+
IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
160160
return IPX_ERR_NOMEM;
161161
}
162162
break;
163163
case NODE_TRAP_IFC_FLUSH_TIMEOUT:
164164
assert(content->type == FDS_OPTS_T_STRING);
165165
cnf->trap_ifc_autoflush = strdup(content->ptr_string);
166166
if(cnf->trap_ifc_autoflush == NULL) {
167-
IPX_CTX_ERROR(ctx, "Unable to allocate memory for trap interface autoflush.");
167+
IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
168168
return IPX_ERR_NOMEM;
169169
}
170170
break;
171171
case NODE_TRAP_IFC_BUFFER_SWITCH:
172172
assert(content->type == FDS_OPTS_T_STRING);
173173
cnf->trap_ifc_bufferswitch = strdup(content->ptr_string);
174174
if(cnf->trap_ifc_bufferswitch == NULL) {
175-
IPX_CTX_ERROR(ctx, "Unable to allocate memory for trap interface buffer switch.");
175+
IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
176176
return IPX_ERR_NOMEM;
177177
}
178178
break;
179179
case NODE_UNIREC_FORMAT:
180180
assert(content->type == FDS_OPTS_T_STRING);
181181
cnf->unirec_format = strdup(content->ptr_string);
182182
if(cnf->unirec_format == NULL) {
183-
IPX_CTX_ERROR(ctx, "Unable to allocate memory for unirec format.");
183+
IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
184184
return IPX_ERR_NOMEM;
185185
}
186186
break;

0 commit comments

Comments
 (0)