чување f8eac8a00c134fa6374874bc39b7fe54a132d1f6
родитељ a67d363becb5b53f03f8092fddca395e6ff0a491
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Thu, 3 Mar 2022 14:07:13 +0100
Fix: only chmod if the file is already existing
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 1, додавања: 5(+), брисања: 1(-)
diff --git a/sled.c b/sled.c
@@ -687,6 +687,7 @@ save_file(struct DrawState* state)
struct stat st;
char* real_filename = NULL;
size_t rfn_len = 0;
+ int new_file = 0;
if (!(buf = calloc(MAXBUFLINE, 1))
|| !(real_filename = calloc(MAXPATH, 1)))
@@ -719,6 +720,8 @@ save_file(struct DrawState* state)
== -1)
return SAVE_ERR_CANT_MOVE_FILE;
} /* We don't error out here to account for new files */
+ else
+ new_file = 1;
#endif
if (!(output = fopen(rfn_len > 0 ? real_filename : state->filename,
@@ -733,7 +736,8 @@ save_file(struct DrawState* state)
if (symlink(real_filename, state->filename) == -1)
return SAVE_ERR_CANT_SYMLINK;
}
- chmod(rfn_len > 0 ? real_filename : state->filename, st.st_mode);
+ if (!new_file)
+ chmod(rfn_len > 0 ? real_filename : state->filename, st.st_mode);
#endif
if (state->rows_count == 1 && state->buffer[0].length == 0)