← Commit list

3b33dd9b1

Glenn L McGrath
Glenn L McGrath
2002-12-13
SOURCE BUG Duration: 9s

Subject

Fix possible bug if file length not known

SOURCE BUG

This commit was genuinely broken at the time (not related to our build system): sysdeps/linux/Config.in "fileutils/Config.in" dosyasini kaynak gosteriyor ama bu dosya repoda hic var olmadi (2002-12-05 - 2003-02-15 arasi orijinal yazar hatasi, 3238ea167 ile duzeltildi)

→ Bu hatanin tam hikayesini ve duzeltme diffini gor

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

networking/ftpgetput.c+11 -6
@@ -56,14 +56,20 @@ typedef struct ftp_host_info_s {
static char verbose_flag;
static char do_continue = 0;
-/* If chunksize == 0 read till end of file */
-static int copyfd_chunk(int fd1, int fd2, off_t chunksize)
+static int copyfd_chunk(int fd1, int fd2, const off_t chunksize)
{
size_t nread;
size_t nwritten;
size_t size;
+ size_t remaining;
char buffer[BUFSIZ];
+ if (chunksize) {
+ remaining = chunksize;
+ } else {
+ remaining = -1;
+ }
+
do {
if ((chunksize > BUFSIZ) || (chunksize == 0)) {
size = BUFSIZ;
@@ -73,7 +79,7 @@ static int copyfd_chunk(int fd1, int fd2, off_t chunksize)
nread = safe_read(fd1, buffer, size);
- if (nread < 0) {
+ if (nread <= 0) {
if (chunksize) {
perror_msg_and_die("read error");
} else {
@@ -88,10 +94,9 @@ static int copyfd_chunk(int fd1, int fd2, off_t chunksize)
}
if (chunksize) {
- chunksize -= nwritten;
+ remaining -= nwritten;
}
-
- } while (chunksize);
+ } while (remaining != 0);
return 0;
}