diff options
author | Ian C <ianc@noddybox.co.uk> | 2020-03-05 08:52:30 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2020-03-05 08:52:30 +0000 |
commit | c07f1f0db4d24382a971105e348098f127c9dd5f (patch) | |
tree | f5d01a08c6dcfa025d91eeb2eed2b056cf4adc2a /server/nfts.c | |
parent | 22a3f2e6e1796162542447f45a71bfd0e3288f3a (diff) |
Changed file read/write to use wrapper funcs. Alloc memory for LS command.
Diffstat (limited to 'server/nfts.c')
-rw-r--r-- | server/nfts.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/server/nfts.c b/server/nfts.c index 634f184..afc3994 100644 --- a/server/nfts.c +++ b/server/nfts.c @@ -244,7 +244,7 @@ static int Put(int sock, const char *path) buff = Malloc(len); fd = open(path, O_RDONLY); - read(fd, buff, len); + Read(fd, buff, len); close(fd); if (!Write(sock, "PF", 2)) @@ -331,7 +331,7 @@ static int Get(int sock, const char *path) if (Read(sock, buff, len)) { - write(fd, buff, len); + Write(fd, buff, len); } else { @@ -469,19 +469,22 @@ static int Ls(int sock) { int no; int f; - char buff[1024]; no = ReadSize(sock); for(f = 0; f < no; f++) { int size; + char *buff; size = ReadSize(sock); + buff = Malloc(size+1); Read(sock, buff, size); buff[size] = 0; printf("%s\n", buff); + + free(buff); } } else |