diff --git a/src/filelist.c b/src/filelist.c index 8956238276a59167d5a4dbfd93b06732745ccb0d..ebae08d4cb11613487331e63493761c16c27d83f 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -623,7 +623,8 @@ char *feh_absolute_path(char *path) /* I SHOULD be able to just use a simple realpath() here, but dumb * old Solaris's realpath doesn't return an absolute path if the path you give it is relative. Linux and BSD get this right... */ - getcwd(cwd, sizeof(cwd)); + if (getcwd(cwd, sizeof(cwd)) == NULL) + eprintf("Cannot determine working directory:"); snprintf(temp, sizeof(temp), "%s/%s", cwd, path); if (realpath(temp, fullpath) != NULL) { ret = estrdup(fullpath); diff --git a/src/filelist.h b/src/filelist.h index 79d1e628281f77827aaa232b7193699ed54530f4..91e5fd09129122a428dac8117664d34af5328c99 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -55,6 +55,16 @@ struct __feh_file_info { #define FEH_FILE(l) ((feh_file *) l) #define FEH_MAX_DIRNAME_LEN 4096 +/* + * PATH_MAX may not be defined on all systems. Since we only use it in for a + * getcwd call in feh_absolute_path, it isn't really worth the effort to malloc + * ever-increasing buffers until it fits. Instead, we just set it to 4096 and + * have --filelist and --bg-* hiccup if the path is larger. + */ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + enum filelist_recurse { FILELIST_FIRST, FILELIST_CONTINUE, FILELIST_LAST }; enum sort_type {