@ -291,15 +291,24 @@ static inline int PacketAlertSetContext(
if ( det_ctx - > json_content_len ) {
/* We have some JSON attached in the current detection so let's try
to see if some need to be used for current signature . */
struct PacketContextData * current_json = SCCalloc ( 1 , sizeof ( struct PacketContextData ) ) ;
if ( current_json = = NULL ) {
/* Allocation error, let's return now */
return - 1 ;
}
pa - > json_info = current_json ;
for ( size_t i = 0 ; i < det_ctx - > json_content_len ; i + + ) {
struct PacketContextData * current_json = NULL ;
for ( uint8_t i = 0 ; i < det_ctx - > json_content_len ; i + + ) {
if ( s = = det_ctx - > json_content [ i ] . id ) {
if ( current_json - > json_string ! = NULL ) {
SCLogDebug ( " signature %p, content index %u " , s , i ) ;
if ( current_json = = NULL ) {
/* Allocate the first one */
current_json = SCCalloc ( 1 , sizeof ( struct PacketContextData ) ) ;
if ( current_json = = NULL ) {
/* Allocation error, let's return now */
return - 1 ;
}
if ( pa - > json_info = = NULL ) {
/* If this is the first one, set it */
pa - > json_info = current_json ;
}
current_json - > next = NULL ;
} else {
/* Allocate the next one */
struct PacketContextData * next_json =
SCCalloc ( 1 , sizeof ( struct PacketContextData ) ) ;
if ( next_json ) {
@ -311,7 +320,9 @@ static inline int PacketAlertSetContext(
return - 1 ;
}
}
current_json - > json_string = det_ctx - > json_content [ i ] . json_content ;
current_json - > json_string = SCStrdup ( det_ctx - > json_content [ i ] . json_content ) ;
SCLogDebug ( " json content %u, value '%s' (%p) " , ( unsigned int ) i ,
current_json - > json_string , s ) ;
}
}
}