A helper file for cleanup.c.
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index e8043c5..08a75b2 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -1228,11 +1228,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                        }
                }
 
-               if (fn != fbuf) {
-                       if (len >= MAXPATHLEN)
-                               overflow_exit("send_file_list");
+               if (fn != fbuf)
                        memmove(fbuf, fn, len + 1);
-               }
 
                if (implied_dirs && (p=strrchr(fbuf,'/')) && p != fbuf) {
                        /* Send the implied directories at the start of the
@@ -1700,15 +1697,15 @@ static void output_flist(struct file_list *flist)
        for (i = 0; i < flist->count; i++) {
                file = flist->files[i];
                if ((am_root || am_sender) && preserve_uid)
-                       sprintf(uidbuf, " uid=%ld", (long)file->uid);
+                       snprintf(uidbuf, sizeof uidbuf, " uid=%ld", (long)file->uid);
                else
                        *uidbuf = '\0';
                if (preserve_gid && file->gid != GID_NONE)
-                       sprintf(gidbuf, " gid=%ld", (long)file->gid);
+                       snprintf(gidbuf, sizeof gidbuf, " gid=%ld", (long)file->gid);
                else
                        *gidbuf = '\0';
                if (!am_sender)
-                       sprintf(depthbuf, "%d", file->dir.depth);
+                       snprintf(depthbuf, sizeof depthbuf, "%d", file->dir.depth);
                rprintf(FINFO, "[%s] i=%d %s %s%s%s%s mode=0%o len=%.0f%s%s flags=%x\n",
                        who, i, am_sender ? NS(file->dir.root) : depthbuf,
                        file->dirname ? file->dirname : "",
@@ -1876,9 +1873,9 @@ char *f_name(struct file_struct *f, char *fbuf)
                int len = strlen(f->dirname);
                memcpy(fbuf, f->dirname, len);
                fbuf[len] = '/';
-               strcpy(fbuf + len + 1, f->basename);
+               strlcpy(fbuf + len + 1, f->basename, MAXPATHLEN - (len + 1));
        } else
-               strcpy(fbuf, f->basename);
+               strlcpy(fbuf, f->basename, MAXPATHLEN);
 
        return fbuf;
 }