summaryrefslogtreecommitdiff
path: root/src/ivysocket.c
diff options
context:
space:
mode:
authorfcolin2007-12-13 13:58:51 +0000
committerfcolin2007-12-13 13:58:51 +0000
commit054f451ee3b79c21ab9cca9cda3154875f5fc972 (patch)
tree5624ec96cb3cbd123b01f07ba6540aeb8fc1c493 /src/ivysocket.c
parent0acdf45640c8be6413637afe1091ea640a936303 (diff)
downloadivy-c-054f451ee3b79c21ab9cca9cda3154875f5fc972.zip
ivy-c-054f451ee3b79c21ab9cca9cda3154875f5fc972.tar.gz
ivy-c-054f451ee3b79c21ab9cca9cda3154875f5fc972.tar.bz2
ivy-c-054f451ee3b79c21ab9cca9cda3154875f5fc972.tar.xz
correction d'un bug en cas de reallocation de buffer
Diffstat (limited to 'src/ivysocket.c')
-rw-r--r--src/ivysocket.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ivysocket.c b/src/ivysocket.c
index 8430bd3..91aabf3 100644
--- a/src/ivysocket.c
+++ b/src/ivysocket.c
@@ -116,10 +116,12 @@ static void HandleSocket (Channel channel, HANDLE fd, void *data)
char *ptr_nl;
long nb_to_read = 0;
long nb;
+ long nb_occuped;
socklen_t len;
/* limitation taille buffer */
- nb_to_read = client->buffer_size - (client->ptr - client->buffer );
+ nb_occuped = client->ptr - client->buffer;
+ nb_to_read = client->buffer_size - nb_occuped;
if (nb_to_read == 0 ) {
client->buffer_size *= 2; /* twice old size */
client->buffer = realloc( client->buffer, client->buffer_size );
@@ -129,7 +131,8 @@ static void HandleSocket (Channel channel, HANDLE fd, void *data)
exit(0);
}
fprintf(stderr, "Buffer Limit reached realloc new size %ld\n", client->buffer_size );
- nb_to_read = client->buffer_size - (client->ptr - client->buffer );
+ nb_to_read = client->buffer_size - nb_occuped;
+ client->ptr = client->buffer + nb_occuped;
}
len = sizeof (client->from );
nb = recvfrom (fd, client->ptr, nb_to_read,0,(struct sockaddr *)&client->from,