being opened twice but closed once. The process eventually died with
an out of file descriptors error.
/* open tmp file */
if (strlen(fname) > (MAXPATHLEN-8)) {
fprintf(FERROR,"filename too long\n");
/* open tmp file */
if (strlen(fname) > (MAXPATHLEN-8)) {
fprintf(FERROR,"filename too long\n");
continue;
}
sprintf(fnametmp,"%s.XXXXXX",fname);
continue;
}
sprintf(fnametmp,"%s.XXXXXX",fname);
continue;
}
fd2 = open(fnametmp,O_WRONLY|O_CREAT,file->mode);
continue;
}
fd2 = open(fnametmp,O_WRONLY|O_CREAT,file->mode);
- if (relative_paths && errno == ENOENT &&
+ if (fd2 == -1 && relative_paths && errno == ENOENT &&
create_directory_path(fnametmp) == 0) {
fd2 = open(fnametmp,O_WRONLY|O_CREAT,file->mode);
}
create_directory_path(fnametmp) == 0) {
fd2 = open(fnametmp,O_WRONLY|O_CREAT,file->mode);
}
/* map the local file */
if (fstat(fd,&st) != 0) {
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
/* map the local file */
if (fstat(fd,&st) != 0) {
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));