Skip to content

Commit

Permalink
Silence a few flawfinder warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-arch committed Dec 23, 2024
1 parent 5385179 commit 5d7dc37
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ xmkdir(const char *dir, const mode_t mode)
{
mode_t old_mask = umask(0077); /* flawfinder: ignore */
int ret = mkdirat(XAT_FDCWD, dir, mode);
umask(old_mask);
umask(old_mask); /* flawfinder: ignore */

if (ret == -1)
return FUNC_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/colors.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ import_color_scheme(const char *name)
char *cmd[] = {"cp", "--", dfile, colors_dir, NULL};
const mode_t old_mask = umask(0077); /* flawfinder: ignore */
const int ret = launch_execv(cmd, FOREGROUND, E_NOFLAG);
umask(old_mask);
umask(old_mask); /* flawfinder: ignore */

return ret == FUNC_SUCCESS ? ret : FUNC_FAILURE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ import_from_data_dir(const char *src_filename, char *dest, const int exec)
const mode_t old_umask = umask(exec == 1 ? 0077 : 0177); /* flawfinder: ignore */
char *cmd[] = {"cp", "--", sys_file, dest, NULL};
const int ret = launch_execv(cmd, FOREGROUND, E_NOSTDERR);
umask(old_umask);
umask(old_umask); /* flawfinder: ignore */

if (ret == FUNC_SUCCESS) {
#ifndef __MSYS__
Expand Down Expand Up @@ -3591,7 +3591,7 @@ read_config(void)
ret = sscanf(line + 6, "%o\n", &opt_num);
if (ret == -1 || opt_num > MAX_UMASK)
continue;
umask((mode_t)opt_num);
umask((mode_t)opt_num); /* flawfinder: ignore */
}

else if (xargs.welcome_message == UNSET && *line == 'W'
Expand Down
4 changes: 2 additions & 2 deletions src/file_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ umask_function(char *arg)
/* umask is set to zero, and then changed back, only to get the
* current value. */
printf("%04o\n", old_umask);
umask(old_umask);
umask(old_umask); /* flawfinder: ignore */
return FUNC_SUCCESS;
}

Expand All @@ -119,7 +119,7 @@ umask_function(char *arg)
if (new_umask < 0 || new_umask > MAX_UMASK)
goto ERROR;

umask((mode_t)new_umask);
umask((mode_t)new_umask); /* flawfinder: ignore */
printf(_("File-creation mask set to '%04o'\n"), new_umask);
return FUNC_SUCCESS;

Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ main(int argc, char *argv[])
init_workspaces_opts();

/* Restore user umask */
umask(old_mask);
umask(old_mask); /* flawfinder: ignore */

/* # 2. MAIN PROGRAM LOOP # */
run_main_loop();
Expand Down
4 changes: 2 additions & 2 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ read_inotify(void)
char inotify_buf[EVENT_BUF_LEN];

memset((void *)inotify_buf, '\0', sizeof(inotify_buf));
i = (int)read(inotify_fd, inotify_buf, sizeof(inotify_buf));
i = (int)read(inotify_fd, inotify_buf, sizeof(inotify_buf)); /* flawfinder: ignore */

if (i <= 0) {
# ifdef INOTIFY_DEBUG
Expand Down Expand Up @@ -1887,7 +1887,7 @@ handle_stdin(void)
char *buf = xnmalloc(chunk, sizeof(char));

while (chunks_n < max_chunks) {
input_len = read(STDIN_FILENO, buf + total_len, chunk);
input_len = read(STDIN_FILENO, buf + total_len, chunk); /* flawfinder: ignore */

/* Error */
if (input_len < 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/tabcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ ctrl-d:deselect-all,ctrl-t:toggle-all" : "",
flags &= ~DELAYED_REFRESH;
const mode_t old_mask = umask(0077); /* flawfinder: ignore */
const int ret = launch_execl(cmd);
umask(old_mask);
umask(old_mask); /* flawfinder: ignore */

if (restore_cwd == 1)
xchdir(workspaces[cur_ws].path, NO_TITLE);
Expand Down

0 comments on commit 5d7dc37

Please sign in to comment.