summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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 9d8b38a..49355c4 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -402,7 +402,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 9ee4c08..fc81bdd 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -637,9 +637,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 9154d2d..87ec4cb 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -385,7 +385,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 b62d28b..5adb3ca 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -382,7 +382,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) {