fix valgrind issue for SMB test. Small restructuring. probing_parsers global variable now part of AlpProtoDetectCtx

remotes/origin/master-1.1.x
Anoop Saldanha 15 years ago committed by Victor Julien
parent 7f8fb0f00d
commit 6e0d98d9c4

@ -247,6 +247,7 @@ void AlpProtoTestDestroy(AlpProtoDetectCtx *ctx) {
mpm_table[ctx->toserver.mpm_ctx.mpm_type].DestroyCtx(&ctx->toserver.mpm_ctx);
mpm_table[ctx->toclient.mpm_ctx.mpm_type].DestroyCtx(&ctx->toclient.mpm_ctx);
AlpProtoFreeSignature(ctx->head);
AppLayerFreeProbingParsers(ctx->probing_parsers);
}
#endif
@ -255,6 +256,7 @@ void AlpProtoDestroy() {
mpm_table[alp_proto_ctx.toserver.mpm_ctx.mpm_type].DestroyCtx(&alp_proto_ctx.toserver.mpm_ctx);
mpm_table[alp_proto_ctx.toclient.mpm_ctx.mpm_type].DestroyCtx(&alp_proto_ctx.toclient.mpm_ctx);
MpmPatternIdTableFreeHash(alp_proto_ctx.mpm_pattern_id_store);
AppLayerFreeProbingParsers(alp_proto_ctx.probing_parsers);
SCReturn;
}
@ -512,6 +514,7 @@ uint16_t AppLayerDetectGetProtoProbingParser(AlpProtoDetectCtx *ctx, Flow *f,
uint8_t flags, uint8_t ipproto)
{
AppLayerProbingParserElement *pe = NULL;
AppLayerProbingParser *probing_parsers = ctx->probing_parsers;
AppLayerProbingParser *pp = NULL;
if (flags & STREAM_TOSERVER) {

@ -26,7 +26,7 @@
#include "stream.h"
#include "detect-content.h"
#include "app-layer-parser.h"
/** \brief Signature for proto detection
* \todo we might just use SigMatch here
@ -73,6 +73,7 @@ typedef struct AlpProtoDetectCtx_ {
AlpProtoSignature **map;
AlpProtoSignature *head; /**< list of sigs */
AppLayerProbingParser *probing_parsers;
uint16_t sigs; /**< number of sigs */
} AlpProtoDetectCtx;

File diff suppressed because it is too large Load Diff

@ -165,8 +165,6 @@ typedef struct AppLayerProbingParser_ {
#define APP_LAYER_PROBING_PARSER_PRIORITY_MEDIUM 2
#define APP_LAYER_PROBING_PARSER_PRIORITY_LOW 3
extern AppLayerProbingParser *probing_parsers;
static inline
AppLayerProbingParser *AppLayerGetProbingParsers(AppLayerProbingParser *probing_parsers,
uint16_t ip_proto,
@ -186,6 +184,8 @@ AppLayerProbingParser *AppLayerGetProbingParsers(AppLayerProbingParser *probing_
return pp;
}
struct AlpProtoDetectCtx_;
/* prototypes */
void AppLayerParsersInitPostProcess(void);
void RegisterAppLayerParsers(void);
@ -199,7 +199,7 @@ int AppLayerRegisterParser(char *name, uint16_t proto, uint16_t parser_id,
AppLayerParserState *parser_state, uint8_t *input,
uint32_t input_len, AppLayerParserResult *output),
char *dependency);
void AppLayerRegisterProbingParser(AppLayerProbingParser **, uint16_t, uint16_t,
void AppLayerRegisterProbingParser(struct AlpProtoDetectCtx_ *, uint16_t, uint16_t,
const char *, uint16_t,
uint16_t, uint16_t, uint8_t, uint8_t,
uint8_t, uint16_t (*ProbingParser)

@ -1375,7 +1375,7 @@ void RegisterSMBParsers(void) {
AppLayerRegisterTransactionIdFuncs(ALPROTO_SMB,
SMBUpdateTransactionId, NULL);
AppLayerRegisterProbingParser(&probing_parsers,
AppLayerRegisterProbingParser(&alp_proto_ctx,
139,
IPPROTO_TCP,
"smb",
@ -1972,7 +1972,6 @@ int SMBParserTest05(void)
int result = 0;
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
AppLayerProbingParser *probing_parsers = NULL;
uint16_t alproto;
Flow f;
memset(&f, 0, sizeof(f));
@ -1988,7 +1987,7 @@ int SMBParserTest05(void)
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_SMB2, "|fe|SMB", 8, 4, STREAM_TOCLIENT);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_SMB2, "|fe|SMB", 8, 4, STREAM_TOSERVER);
AppLayerRegisterProbingParser(&probing_parsers,
AppLayerRegisterProbingParser(&ctx,
f.dp,
IPPROTO_TCP,
"smb",
@ -2002,7 +2001,7 @@ int SMBParserTest05(void)
AlpProtoFinalizeGlobal(&ctx);
AlpProtoFinalizeThread(&ctx, &tctx);
alproto = AppLayerDetectGetProto(&alp_proto_ctx, &tctx, &f,
alproto = AppLayerDetectGetProto(&ctx, &tctx, &f,
smbbuf1, smblen1,
STREAM_TOSERVER, IPPROTO_TCP);
if (alproto != ALPROTO_UNKNOWN) {
@ -2011,7 +2010,7 @@ int SMBParserTest05(void)
goto end;
}
alproto = AppLayerDetectGetProto(&alp_proto_ctx, &tctx, &f,
alproto = AppLayerDetectGetProto(&ctx, &tctx, &f,
smbbuf2, smblen2,
STREAM_TOSERVER, IPPROTO_TCP);
if (alproto != ALPROTO_SMB) {
@ -2023,7 +2022,6 @@ int SMBParserTest05(void)
result = 1;
end:
AlpProtoTestDestroy(&ctx);
AppLayerFreeProbingParsers(probing_parsers);
PmqFree(&tctx.toclient.pmq);
PmqFree(&tctx.toserver.pmq);
return result;
@ -2058,7 +2056,6 @@ int SMBParserTest06(void)
int result = 0;
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
AppLayerProbingParser *probing_parsers = NULL;
uint16_t alproto;
Flow f;
memset(&f, 0, sizeof(f));
@ -2074,7 +2071,7 @@ int SMBParserTest06(void)
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_SMB2, "|fe|SMB", 8, 4, STREAM_TOCLIENT);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_SMB2, "|fe|SMB", 8, 4, STREAM_TOSERVER);
AppLayerRegisterProbingParser(&probing_parsers,
AppLayerRegisterProbingParser(&ctx,
f.dp,
IPPROTO_TCP,
"smb",
@ -2088,7 +2085,7 @@ int SMBParserTest06(void)
AlpProtoFinalizeGlobal(&ctx);
AlpProtoFinalizeThread(&ctx, &tctx);
alproto = AppLayerDetectGetProto(&alp_proto_ctx, &tctx, &f,
alproto = AppLayerDetectGetProto(&ctx, &tctx, &f,
smbbuf1, smblen1,
STREAM_TOSERVER, IPPROTO_TCP);
if (alproto != ALPROTO_UNKNOWN) {
@ -2097,7 +2094,7 @@ int SMBParserTest06(void)
goto end;
}
alproto = AppLayerDetectGetProto(&alp_proto_ctx, &tctx, &f,
alproto = AppLayerDetectGetProto(&ctx, &tctx, &f,
smbbuf2, smblen2,
STREAM_TOSERVER, IPPROTO_TCP);
if (alproto != ALPROTO_SMB) {
@ -2109,7 +2106,6 @@ int SMBParserTest06(void)
result = 1;
end:
AlpProtoTestDestroy(&ctx);
AppLayerFreeProbingParsers(probing_parsers);
PmqFree(&tctx.toclient.pmq);
PmqFree(&tctx.toserver.pmq);
return result;

Loading…
Cancel
Save