From z@|er@b@rutcuog|u @end|ng |rom gm@||@com  Tue Oct 12 08:04:40 2021
From: z@|er@b@rutcuog|u @end|ng |rom gm@||@com (Zafer Barutcuoglu)
Date: Tue, 12 Oct 2021 02:04:40 -0400
Subject: [Rd] int overflow writing long vectors to socketConnection
Message-ID: <0E317F6A-E81C-47E5-9388-F14A8F392B87@gmail.com>

Hi,

Writing >=2GB to a socketConnection (e.g. via writeBin) does not work correctly, because of this int typecast in modules/internet/sockconn.c:
> static size_t sock_write(const void *ptr, size_t size, size_t nitems,
> 			 Rconnection con)
> {
>     Rsockconn this = (Rsockconn)con->private;
>     ssize_t n = R_SockWrite(this->fd, ptr, (int)(size * nitems),
> 			    this->timeout)/((ssize_t)size);
>     return n > 0 ? n : 0;
> }
which seems uncalled for, given:
> ssize_t R_SockWrite(int sockp, const void *buf, size_t len, int timeout)


Is there a rationale for it, or should it be fixed?

Best,
--
Zafer


	[[alternative HTML version deleted]]



[Rd] int overflow writing long vectors to socketConnection
Zafer Barutcuoglu