← Commit list

1643f4198

Glenn L McGrath
Glenn L McGrath
2002-12-18
SOURCE BUG Duration: 30s

Subject

When retrieving a file dont open file until we have to to prevent files of size 0 being created when retrieval fails, bug found by Jeff Angielski

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+8 -8
@@ -174,16 +174,9 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local
filesize = atol(buf + 4);
}
- /* only make a local file if we know that one exists on the remote server */
- if (do_continue) {
- fd_local = xopen(local_file, O_APPEND | O_WRONLY);
- } else {
- fd_local = xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY);
- }
-
if (do_continue) {
struct stat sbuf;
- if (fstat(fd_local, &sbuf) < 0) {
+ if (lstat(local_file, &sbuf) < 0) {
perror_msg_and_die("fstat()");
}
if (sbuf.st_size > 0) {
@@ -206,6 +199,13 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local
error_msg_and_die("RETR error: %s", buf + 4);
}
+ /* only make a local file if we know that one exists on the remote server */
+ if (do_continue) {
+ fd_local = xopen(local_file, O_APPEND | O_WRONLY);
+ } else {
+ fd_local = xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY);
+ }
+
/* Copy the file */
if (copyfd(fd_data, fd_local, filesize) == -1) {
exit(EXIT_FAILURE);