diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-06-08 07:14:28 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-06-08 07:14:28 (GMT) |
commit | 5e2b640532f36e5ad5e616a52a371d20edd78d01 (patch) | |
tree | ca7c19902da573d05b328679906dfeb37325e62b /src | |
parent | dac827b81a8e29cb83fb17985ad5e83770cd833f (diff) |
Receive blocks of data bigger than TLS records if needed.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/packed.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/common/packed.c b/src/common/packed.c index d246de8..b8ed21b 100644 --- a/src/common/packed.c +++ b/src/common/packed.c @@ -591,7 +591,10 @@ bool ssl_recv_packed_buffer(packed_buffer_t *pbuf, SSL *fd) { bool result; /* Bilan à retourner */ uint32_t used; /* Taille de charge utile */ - int got; /* Quantité de données traitées*/ + size_t pos; /* Localisation du stockage */ + size_t remaining; /* Quantité à lire restante */ + size_t got; /* QUantité lue par appel */ + int ret; /* Code de retour d'une lecture*/ got = SSL_read(fd, &used, sizeof(uint32_t)); if (got <= 0) LOG_ERROR_OPENSSL; @@ -610,10 +613,28 @@ bool ssl_recv_packed_buffer(packed_buffer_t *pbuf, SSL *fd) pbuf->used = used; - got = SSL_read(fd, pbuf->data + pbuf->pos, used); - if (got <= 0) LOG_ERROR_OPENSSL; + pos = pbuf->pos; + remaining = used; - result = (got == used); + while (remaining > 0) + { + ret = SSL_read_ex(fd, pbuf->data + pos, remaining, &got); + + if (ret > 0) + { + pos += got; + remaining -= got; + } + + else + { + LOG_ERROR_OPENSSL; + break; + } + + } + + result = (remaining == 0); } |