summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/packed.c29
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);
}