summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOlof-Joachim Frahm <olof@shiftleft.io>2020-05-29 11:41:58 +0200
committerOlof-Joachim Frahm <olof@shiftleft.io>2020-05-29 11:41:58 +0200
commita23571495beb95e146755e16b1a02dff03624625 (patch)
treee373c1e1e68539407a076003f8b92254941cce17 /src
parentc9e024daeb43094696a05c8d03ef6682ed683dae (diff)
Fix some warnings from `gcc`.
Diffstat (limited to 'src')
-rw-r--r--src/feh_png.c5
-rw-r--r--src/filelist.c5
-rw-r--r--src/imlib.c4
-rw-r--r--src/slideshow.c3
-rw-r--r--src/wallpaper.c5
5 files changed, 14 insertions, 8 deletions
diff --git a/src/feh_png.c b/src/feh_png.c
index d0c1c8a..8f5b94d 100644
--- a/src/feh_png.c
+++ b/src/feh_png.c
@@ -197,7 +197,10 @@ int feh_png_file_is_png(FILE * fp)
{
unsigned char buf[8];
- fread(buf, 1, 8, fp);
+ if (fread(buf, 1, 8, fp) != 8) {
+ return 0;
+ }
+
if (png_sig_cmp(buf, 0, 8)) {
return 0;
}
diff --git a/src/filelist.c b/src/filelist.c
index 4939d4d..d5b0750 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -398,7 +398,7 @@ void feh_file_dirname(char *dst, feh_file * f, int maxlen)
return;
}
- strncpy(dst, f->filename, n);
+ memcpy(dst, f->filename, n);
dst[n] = '\0';
}
@@ -650,7 +650,8 @@ char *feh_absolute_path(char *path)
path you give it is relative. Linux and BSD get this right... */
if (getcwd(cwd, sizeof(cwd)) == NULL)
eprintf("Cannot determine working directory:");
- snprintf(temp, sizeof(temp), "%s/%s", cwd, path);
+ if ((size_t) snprintf(temp, sizeof(temp), "%s/%s", cwd, path) >= sizeof(temp))
+ eprintf("Absolute path for working directory was truncated");
if (realpath(temp, fullpath) != NULL) {
ret = estrdup(fullpath);
} else {
diff --git a/src/imlib.c b/src/imlib.c
index 5034be8..62d88c6 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -494,9 +494,7 @@ static char *feh_dcraw_load_image(char *filename)
close(fd);
return NULL;
} else if (childpid == 0) {
-
- close(1);
- dup(fd);
+ dup2(fd, STDOUT_FILENO);
close(fd);
alarm(opt.conversion_timeout);
diff --git a/src/slideshow.c b/src/slideshow.c
index 00425d1..591848c 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -364,7 +364,8 @@ void feh_action_run(feh_file * file, char *action, winwidget winwid)
if (opt.verbose && !opt.list && !opt.customlist)
fprintf(stderr, "Running action -->%s<--\n", sys);
- system(sys);
+ if (system(sys) == -1)
+ perror("running action via system() failed");
}
return;
}
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 37b5a1d..62b36a4 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -282,7 +282,10 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
feh_wm_load_next(&im);
fil = FEH_FILE(filelist->data)->filename;
}
- snprintf(sendbuf, sizeof(sendbuf), "background %s bg.file %s", bgname, fil);
+ if ((size_t) snprintf(sendbuf, sizeof(sendbuf), "background %s bg.file %s", bgname, fil) >= sizeof(sendbuf)) {
+ weprintf("Writing to IPC send buffer was truncated");
+ return;
+ }
enl_ipc_send(sendbuf);
if (scaled) {