From 916d08f8d02fe9c08ed2574fc5dbe55a00a2e3e2 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 1 Aug 2020 21:04:24 +0300 Subject: [PATCH] fixed filenames returned by flist --- server/src/client.c | 2 +- src/proto.c | 10 +++++----- src/proto.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) 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); -- 1.7.10.4