Skip to content

Commit

Permalink
Fix file permission at creation
Browse files Browse the repository at this point in the history
  • Loading branch information
drawbu committed Mar 7, 2024
1 parent 4442d79 commit ec03045
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/messages/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ void msg_retr(client_t *client, const char *buffer)
static void upload_file(int fd, client_t *client, const char *filename)
{
char buff[BUFSIZ];
int file = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
int file = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);

if (file == -1) {
client_write(client, MSG_450);
return;
}
client_write(client, MSG_150);
for (ssize_t size = sizeof(buff); size == sizeof(buff);) {
size = read(fd, buff, sizeof(buff));
size = read(fd, buff, size);
write(file, buff, size);
}
client_write(client, MSG_226);
Expand Down

0 comments on commit ec03045

Please sign in to comment.