Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions sslscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -4779,6 +4779,16 @@ void bs_append_bs(bs *dst, bs *src) {
bs_append_bytes(dst, src->buf, src->len);
}

/* Returns the number of bytes in this byte string. */
size_t bs_reset(bs *b) {
if (b == NULL)
return 0;

b->len = 0;

return 0;
}

/* Returns the number of bytes in this byte string. */
size_t bs_get_len(bs *b) {
if (b == NULL)
Expand Down Expand Up @@ -5287,22 +5297,26 @@ bs *getTLSHandshakeRecord(int s) {
bs *tls_record = NULL;
bs_new_size(&tls_record, 512);

/* Read in the first 5 bytes to get the length of the rest of the record. */
int err = bs_read_socket(tls_record, s, 5);
if (err != 0)
goto err;
while (1) {
/* Read in the first 5 bytes to get the length of the rest of the record. */
int err = bs_read_socket(tls_record, s, 5);
if (err != 0)
goto err;

/* Ensure that the Content Type is Handshake (22). */
if (bs_get_byte(tls_record, 0) != 0x16)
goto err;
/* Get the length of the record. */
unsigned short packet_len = (bs_get_byte(tls_record, 3) << 8) | bs_get_byte(tls_record, 4);

/* Read in the rest of the record. */
err = bs_read_socket(tls_record, s, packet_len);
if (err != 0)
goto err;

/* Get the length of the record. */
unsigned short packet_len = (bs_get_byte(tls_record, 3) << 8) | bs_get_byte(tls_record, 4);
/* Find that the Content Type is Handshake (22). */
if (bs_get_byte(tls_record, 0) == 0x16)
break;

/* Read in the rest of the record. */
err = bs_read_socket(tls_record, s, packet_len);
if (err != 0)
goto err;
bs_reset(tls_record);
}

return tls_record;

Expand Down