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 15 years ago
parent 9d7baa7a9f
commit 1d73e1fb7e

@ -526,7 +526,7 @@ end:
if (mpm_table[dir->mpm_ctx.mpm_type].Cleanup != NULL) {
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");
switch (proto) {
case ALPROTO_HTTP:

@ -153,7 +153,7 @@ static int SSHParseServerVersion(Flow *f, void *ssh_state, AppLayerParserState *
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);
if (state->server_proto_version == NULL) {
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);
if (state->server_software_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -486,7 +486,7 @@ static int SSHParseClientVersion(Flow *f, void *ssh_state, AppLayerParserState *
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);
if (state->client_proto_version == NULL) {
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);
if (state->client_software_version == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -732,7 +732,7 @@ static void *SSHStateAlloc(void)
*/
static void SSHStateFree(void *state)
{
SshState *s= (SshState *)state;
SshState *s = (SshState *)state;
if (s->client_proto_version != NULL)
SCFree(s->client_proto_version);
if (s->client_software_version != NULL)

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

@ -1527,8 +1527,6 @@ int StreamTcpReassembleHandleSegmentUpdateACK (TcpReassemblyThreadCtx *ra_ctx,
if (!(ssn->flags & STREAMTCP_FLAG_TOSERVER_REASSEMBLY_STARTED)) {
SCLogDebug("toserver reassembling is not done yet, so "
"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);
}
}

Loading…
Cancel
Save