aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <lucaderi@users.noreply.github.com>2020-04-30 19:53:16 +0200
committerGitHub <noreply@github.com>2020-04-30 19:53:16 +0200
commit6f79b78f7122f904d17709a800b59d60551c1bde (patch)
tree8267b3735d3df7b136ce87068d2f6d18934d20de
parentbd0fd6cf8d8b39bed1f0fa049905d7f6e43af5f0 (diff)
parenta70fd6ed3b33d9e2c89fe35c96102c156d39f1f9 (diff)
Merge pull request #891 from catenacyber/ghsl2
Better fix for integer overflow in SSH
-rw-r--r--src/lib/protocols/ssh.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/protocols/ssh.c b/src/lib/protocols/ssh.c
index 849dbeed4..2b7e69aac 100644
--- a/src/lib/protocols/ssh.c
+++ b/src/lib/protocols/ssh.c
@@ -114,7 +114,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
goto invalid_payload;
/* ssh.server_host_key_algorithms [None] */
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
- if (len > UINT32_MAX - 4 - offset)
+ if (len > UINT32_MAX - 8 - offset)
goto invalid_payload;
offset += 4 + len;
@@ -132,7 +132,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
buf_out_len += len;
buf[buf_out_len++] = ';';
}
- if (len > UINT32_MAX - offset)
+ if (len > UINT32_MAX - 4 - offset)
goto invalid_payload;
offset += len;
@@ -150,7 +150,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
buf_out_len += len;
buf[buf_out_len++] = ';';
}
- if (len > UINT32_MAX - offset)
+ if (len > UINT32_MAX - 4 - offset)
goto invalid_payload;
offset += len;
@@ -168,7 +168,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
buf_out_len += len;
buf[buf_out_len++] = ';';
}
- if (len > UINT32_MAX - offset)
+ if (len > UINT32_MAX - 4 - offset)
goto invalid_payload;
offset += len;
@@ -186,7 +186,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
buf_out_len += len;
buf[buf_out_len++] = ';';
}
- if (len > UINT32_MAX - offset)
+ if (len > UINT32_MAX - 4 - offset)
goto invalid_payload;
offset += len;
@@ -203,7 +203,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
strncpy(&buf[buf_out_len], (const char *)&packet->payload[offset], len);
buf_out_len += len;
}
- if (len > UINT32_MAX - offset)
+ if (len > UINT32_MAX - 4 - offset)
goto invalid_payload;
offset += len;