aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2003-08-04 21:00:57 +0000
committerWayne Davison <wayned@samba.org>2003-08-04 21:00:57 +0000
commit0c2ef5f42dfb71f2af99e58cd9934fb365f079fb (patch)
tree237e277a5c807dc604f16929022f19b7419b314d
parentca20c7fd625c27f540b0ae5be027cb51700c80e3 (diff)
downloadandroid_external_rsync-0c2ef5f42dfb71f2af99e58cd9934fb365f079fb.tar.gz
android_external_rsync-0c2ef5f42dfb71f2af99e58cd9934fb365f079fb.tar.bz2
android_external_rsync-0c2ef5f42dfb71f2af99e58cd9934fb365f079fb.zip
Make sure that the error message for mkstemp() includes the full
path of where we're trying to create the temp file.
-rw-r--r--receiver.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/receiver.c b/receiver.c
index a46fafe1..00160640 100644
--- a/receiver.c
+++ b/receiver.c
@@ -206,14 +206,15 @@ static int get_tmpname(char *fnametmp, char *fname)
length = strlen(fnametmp);
fnametmp[length++] = '/';
fnametmp[length] = '\0'; /* always NULL terminated */
- }
+ }
- if ((f = strrchr(fname, '/'))) { /* extra () for gcc */
+ if ((f = strrchr(fname, '/')) != NULL) {
++f;
if (!tmpdir) {
length = f - fname;
+ /* copy up to and including the slash */
strlcpy(fnametmp, fname, length + 1);
- } /* copy up to and including the slash */
+ }
} else {
f = fname;
}
@@ -222,8 +223,7 @@ static int get_tmpname(char *fnametmp, char *fname)
maxname = MIN(MAXPATHLEN - 7 - length, NAME_MAX - 8);
- if (maxname < 1)
- {
+ if (maxname < 1) {
rprintf(FERROR, "temporary filename too long: %s\n", fname);
fnametmp[0] = '\0';
return 0;
@@ -466,7 +466,15 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
}
if (fd2 == -1) {
- rprintf(FERROR,"mkstemp %s failed: %s\n",fnametmp,strerror(errno));
+ extern char curr_dir[];
+ char *p1, *p2;
+ if (*fnametmp == '.') {
+ p1 = curr_dir;
+ p2 = "/";
+ } else
+ p1 = p2 = "";
+ rprintf(FERROR, "mkstemp %s%s%s failed: %s\n",
+ p1, p2, fnametmp, strerror(errno));
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
if (fd1 != -1) close(fd1);