From: John Tsiombikas Date: Sat, 1 Aug 2020 18:04:24 +0000 (+0300) Subject: fixed filenames returned by flist X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=916d08f8d02fe9c08ed2574fc5dbe55a00a2e3e2;p=reposerve fixed filenames returned by flist --- diff --git a/server/src/client.c b/server/src/client.c index e7f4d3c..1ee31bb 100644 --- a/server/src/client.c +++ b/server/src/client.c @@ -137,7 +137,7 @@ static struct flist *gen_flist(int contents) } } sprintf(pathbuf, "%s/%s", repo_path, repo_file(i)->path); - flist_add(flist, pathbuf, contents); + flist_add(flist, repo_file(i)->path, pathbuf, contents); } repo_cleanup(); diff --git a/src/proto.c b/src/proto.c index 7d6466c..9701ab4 100644 --- a/src/proto.c +++ b/src/proto.c @@ -28,7 +28,7 @@ void flist_destroy(struct flist *flist) } } -int flist_add(struct flist *flist, const char *fname, int contents) +int flist_add(struct flist *flist, const char *name, const char *path, int contents) { FILE *fp; struct proto_file_entry fent; @@ -43,8 +43,8 @@ int flist_add(struct flist *flist, const char *fname, int contents) return -1; } - if(!(fp = fopen(fname, "rb"))) { - fprintf(stderr, "flist_add: failed to open file: %s: %s\n", fname, strerror(errno)); + if(!(fp = fopen(path, "rb"))) { + fprintf(stderr, "flist_add: failed to open file: %s: %s\n", path, strerror(errno)); return -1; } fstat(fileno(fp), &st); @@ -52,7 +52,7 @@ int flist_add(struct flist *flist, const char *fname, int contents) fent.size = st.st_size; fent.mtime = st.st_mtime; - namelen = datalen = strlen(fname); + namelen = datalen = strlen(name); if(contents) { datalen += fent.size; } @@ -92,7 +92,7 @@ int flist_add(struct flist *flist, const char *fname, int contents) fent.nameoffs = flist->data_sz; fent.namelen = namelen; dptr = flist->data + flist->data_sz; - memcpy(dptr, fname, namelen); + memcpy(dptr, name, namelen); md5_begin(&md); if(contents) { diff --git a/src/proto.h b/src/proto.h index 3ed1ae7..b03ff7b 100644 --- a/src/proto.h +++ b/src/proto.h @@ -28,7 +28,7 @@ struct flist { struct flist *flist_create(void); void flist_destroy(struct flist *flist); -int flist_add(struct flist *flist, const char *fname, int contents); +int flist_add(struct flist *flist, const char *name, const char *path, int contents); int flist_finalize(struct flist *flist); int read_line(int s, char *buf, int bufsz);