Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
size_t total = 0;
size_t bufsize = MIN(TRANSFER_BUF_SIZE,count);
size_t total_written = 0;
size_t total = 0;
size_t bufsize = MIN(TRANSFER_BUF_SIZE,count);
size_t total_written = 0;
DEBUG(10,("default_sys_recvfile: from = %d, to = %d, "
"offset=%.0f, count = %lu\n",
DEBUG(10,("default_sys_recvfile: from = %d, to = %d, "
"offset=%.0f, count = %lu\n",
- buffer = SMB_MALLOC_ARRAY(char, bufsize);
- if (buffer == NULL) {
- return -1;
- }
-
while (total < count) {
size_t num_written = 0;
ssize_t read_ret;
while (total < count) {
size_t num_written = 0;
ssize_t read_ret;
read_ret = sys_read(fromfd, buffer, toread);
if (read_ret <= 0) {
/* EOF or socket error. */
read_ret = sys_read(fromfd, buffer, toread);
if (read_ret <= 0) {
/* EOF or socket error. */
if (saved_errno) {
/* Return the correct write error. */
errno = saved_errno;
if (saved_errno) {
/* Return the correct write error. */
errno = saved_errno;
{
size_t total = 0;
size_t bufsize = MIN(TRANSFER_BUF_SIZE,count);
{
size_t total = 0;
size_t bufsize = MIN(TRANSFER_BUF_SIZE,count);
int old_flags = 0;
if (count == 0) {
return 0;
}
int old_flags = 0;
if (count == 0) {
return 0;
}
- buffer = SMB_MALLOC_ARRAY(char, bufsize);
- if (buffer == NULL) {
- return -1;
- }
-
old_flags = fcntl(sockfd, F_GETFL, 0);
if (set_blocking(sockfd, true) == -1) {
old_flags = fcntl(sockfd, F_GETFL, 0);
if (set_blocking(sockfd, true) == -1) {
if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
return -1;
}
if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
return -1;
}