Small update to the ssh module: fix a valgrind warning and a couple of compiler warnings. Do a few small style updates.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 9d7baa7a9f
commit 1d73e1fb7e

@ -526,7 +526,7 @@ end:
if (mpm_table[dir->mpm_ctx.mpm_type].Cleanup != NULL) { if (mpm_table[dir->mpm_ctx.mpm_type].Cleanup != NULL) {
mpm_table[dir->mpm_ctx.mpm_type].Cleanup(&tdir->mpm_ctx); mpm_table[dir->mpm_ctx.mpm_type].Cleanup(&tdir->mpm_ctx);
} }
#if 1 #if 0
printf("AppLayerDetectGetProto: returning %" PRIu16 " (%s): ", proto, flags & STREAM_TOCLIENT ? "TOCLIENT" : "TOSERVER"); printf("AppLayerDetectGetProto: returning %" PRIu16 " (%s): ", proto, flags & STREAM_TOCLIENT ? "TOCLIENT" : "TOSERVER");
switch (proto) { switch (proto) {
case ALPROTO_HTTP: case ALPROTO_HTTP:

@ -153,7 +153,7 @@ static int SSHParseServerVersion(Flow *f, void *ssh_state, AppLayerParserState *
SCReturnInt(-1); SCReturnInt(-1);
} }
uint64_t proto_ver_len = (uint64_t)((uint64_t)proto_end - (uint64_t)line_ptr); uint64_t proto_ver_len = (uint64_t)(proto_end - line_ptr);
state->server_proto_version = SCMalloc(proto_ver_len + 1); state->server_proto_version = SCMalloc(proto_ver_len + 1);
if (state->server_proto_version == NULL) { if (state->server_proto_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -180,7 +180,7 @@ static int SSHParseServerVersion(Flow *f, void *ssh_state, AppLayerParserState *
} }
} }
uint64_t sw_ver_len = (uint64_t)((uint64_t)sw_end - (uint64_t)line_ptr); uint64_t sw_ver_len = (uint64_t)(sw_end - line_ptr);
state->server_software_version = SCMalloc(sw_ver_len + 1); state->server_software_version = SCMalloc(sw_ver_len + 1);
if (state->server_software_version == NULL) { if (state->server_software_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -486,7 +486,7 @@ static int SSHParseClientVersion(Flow *f, void *ssh_state, AppLayerParserState *
SCReturnInt(-1); SCReturnInt(-1);
} }
uint64_t proto_ver_len = (uint64_t)((uint64_t)proto_end - (uint64_t)line_ptr); uint64_t proto_ver_len = (uint64_t)(proto_end - line_ptr);
state->client_proto_version = SCMalloc(proto_ver_len + 1); state->client_proto_version = SCMalloc(proto_ver_len + 1);
if (state->client_proto_version == NULL) { if (state->client_proto_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -513,7 +513,7 @@ static int SSHParseClientVersion(Flow *f, void *ssh_state, AppLayerParserState *
} }
} }
uint64_t sw_ver_len = (uint64_t)((uint64_t)sw_end - (uint64_t)line_ptr); uint64_t sw_ver_len = (uint64_t)(sw_end - line_ptr);
state->client_software_version = SCMalloc(sw_ver_len + 1); state->client_software_version = SCMalloc(sw_ver_len + 1);
if (state->client_software_version == NULL) { if (state->client_software_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -732,7 +732,7 @@ static void *SSHStateAlloc(void)
*/ */
static void SSHStateFree(void *state) static void SSHStateFree(void *state)
{ {
SshState *s= (SshState *)state; SshState *s = (SshState *)state;
if (s->client_proto_version != NULL) if (s->client_proto_version != NULL)
SCFree(s->client_proto_version); SCFree(s->client_proto_version);
if (s->client_software_version != NULL) if (s->client_software_version != NULL)

@ -190,6 +190,8 @@ DetectSshVersionData *DetectSshVersionParse (char *str)
if (ssh == NULL) if (ssh == NULL)
goto error; goto error;
memset(ssh, 0x00, sizeof(DetectSshVersionData));
/* If we expect a protocol version 2 or 1.99 (considered 2, we /* If we expect a protocol version 2 or 1.99 (considered 2, we
* will compare it with both strings) */ * will compare it with both strings) */
if (strcmp("2_compat", str_ptr) == 0) { if (strcmp("2_compat", str_ptr) == 0) {
@ -233,7 +235,8 @@ static int DetectSshVersionSetup (DetectEngineCtx *de_ctx, Signature *s, char *s
SigMatch *sm = NULL; SigMatch *sm = NULL;
ssh = DetectSshVersionParse(str); ssh = DetectSshVersionParse(str);
if (ssh == NULL) goto error; if (ssh == NULL)
goto error;
/* Okay so far so good, lets get this into a SigMatch /* Okay so far so good, lets get this into a SigMatch
* and put it in the Signature. */ * and put it in the Signature. */
@ -255,8 +258,10 @@ static int DetectSshVersionSetup (DetectEngineCtx *de_ctx, Signature *s, char *s
return 0; return 0;
error: error:
if (ssh != NULL) DetectSshVersionFree(ssh); if (ssh != NULL)
if (sm != NULL) SCFree(sm); DetectSshVersionFree(ssh);
if (sm != NULL)
SCFree(sm);
return -1; return -1;
} }

@ -1527,8 +1527,6 @@ int StreamTcpReassembleHandleSegmentUpdateACK (TcpReassemblyThreadCtx *ra_ctx,
if (!(ssn->flags & STREAMTCP_FLAG_TOSERVER_REASSEMBLY_STARTED)) { if (!(ssn->flags & STREAMTCP_FLAG_TOSERVER_REASSEMBLY_STARTED)) {
SCLogDebug("toserver reassembling is not done yet, so " SCLogDebug("toserver reassembling is not done yet, so "
"skipping reassembling at the moment for to_client"); "skipping reassembling at the moment for to_client");
printf("toserver reassembling is not done yet, so "
"skipping reassembling at the moment for to_client\n");
SCReturnInt(0); SCReturnInt(0);
} }
} }

Loading…
Cancel
Save