--- lynx2-8-6/src/LYUtils.c.orig 2006-11-07 02:27:15.000000000 +0100 +++ lynx2-8-6/src/LYUtils.c 2007-02-25 21:41:54.554627431 +0100 @@ -5330,7 +5330,9 @@ const char *fname) { char *home = NULL; + char *etc_dir = getenv("ETC_DIR"); const char *file = fname; + char *file2 = NULL; int len; /* @@ -5353,13 +5355,39 @@ /* * Set up home string and length. - FM */ - StrAllocCopy(home, Home_Dir()); - #ifdef VMS #define NO_HOMEPATH "Error:" #else #define NO_HOMEPATH "/error" #endif /* VMS */ + + if (etc_dir) { + StrAllocCopy(home, etc_dir); + if (!non_empty(etc_dir)) + /* + * Home_Dir() has a bug if this ever happens. - FM + */ + StrAllocCopy(etc_dir, NO_HOMEPATH); + + len = fbuffer_size - (strlen(etc_dir) + 1); + if (len <= 0) { + /* + * Buffer is smaller than or only big enough for the home path. + * Load what fits of the home path and return. This will fail, + * but we need something in the buffer. - FM + */ + LYstrncpy(fbuffer, etc_dir, (fbuffer_size - 1)); + return; + } + /* + * Check whether we have a subdirectory path or just a filename. - FM + */ + file2 = (strncmp(file, "./", 2) ? file : file + 2); + sprintf(fbuffer, "%s/%.*s", etc_dir, len, + (strncmp(file2, ".", 1) ? file2 : (file2+1))); + } else { + StrAllocCopy(home, Home_Dir()); + if (!non_empty(home)) /* * Home_Dir() has a bug if this ever happens. - FM @@ -5416,6 +5444,7 @@ (StrNCmp(file, "./", 2) ? file : (file + 2))); #endif /* VMS */ FREE(home); + } } /*