/* open tmp file */
if (strlen(fname) > (MAXPATHLEN-8)) {
fprintf(FERROR,"filename too long\n");
+ close(fd1);
continue;
}
sprintf(fnametmp,"%s.XXXXXX",fname);
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);
}
/* map the local file */
if (fstat(fd,&st) != 0) {
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
+ close(fd);
return -1;
}