telnet: fix heap-overflow error

There is some boilerplate since I removed an if branch and I had to reindent
the code
This commit is contained in:
Nardi Ivan
2020-03-27 11:09:53 +01:00
parent 97fc94c7e8
commit 817aa54214
+2 -5
View File
@@ -36,19 +36,17 @@
static int search_telnet_again(struct ndpi_detection_module_struct *ndpi_struct, static int search_telnet_again(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) { struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
int i;
#ifdef TELNET_DEBUG #ifdef TELNET_DEBUG
printf("==> %s() [%s][direction: %u]\n", __FUNCTION__, packet->payload, packet->packet_direction); printf("==> %s() [%s][direction: %u]\n", __FUNCTION__, packet->payload, packet->packet_direction);
#endif #endif
if (packet->payload == NULL) if (packet->payload == NULL || packet->payload_packet_len == 0)
return(1); return(1);
if(packet->payload[0] == 0xFF) if(packet->payload[0] == 0xFF)
return(1); return(1);
if(packet->payload_packet_len > 0) {
int i;
if(flow->protos.telnet.username_detected) { if(flow->protos.telnet.username_detected) {
if((!flow->protos.telnet.password_found) if((!flow->protos.telnet.password_found)
&& (packet->payload_packet_len > 6)) { && (packet->payload_packet_len > 6)) {
@@ -102,7 +100,6 @@ static int search_telnet_again(struct ndpi_detection_module_struct *ndpi_struct,
flow->protos.telnet.username[flow->protos.telnet.character_id++] = packet->payload[i]; flow->protos.telnet.username[flow->protos.telnet.character_id++] = packet->payload[i];
} }
} }
}
/* Possibly more processing */ /* Possibly more processing */
return(1); return(1);