diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2019-09-28 12:18:17 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2019-09-28 12:27:22 +0200 |
commit | db592aa7256ea36d5dc6d187e674d4680c34cec5 (patch) | |
tree | f98c34c1e9d58b230742a448011307481728bcd3 | |
parent | c82cca7831bd8e9bc65f860b38a847bb5056b5f6 (diff) | |
download | fetchmail-db592aa7256ea36d5dc6d187e674d4680c34cec5.tar.gz fetchmail-db592aa7256ea36d5dc6d187e674d4680c34cec5.tar.bz2 fetchmail-db592aa7256ea36d5dc6d187e674d4680c34cec5.zip |
Regression fix for realpath() buffer.
Let the system allocate realpath() buffers intead
of trying to portably derive a buffer size.
This was found with default GCC fortify settings on
Ubuntu 18.04 and showed with -D_FORTIFY_SOURCE=2 on Fedora, too.
-rw-r--r-- | NEWS | 11 | ||||
-rw-r--r-- | env.c | 26 |
2 files changed, 26 insertions, 11 deletions
@@ -65,11 +65,12 @@ removed from a 6.5.0 or newer release.) fetchmail-6.4.1 (released 2019-09-28, 27459 LoC): -## REGRESSION FIX: -* The bug fix Debian Bug#941129 was incomplete and caused a regression - in the default file locations, so that fetchmail was no longer able to - find it configuration files in some situations. - Reported by Cy Schubert. +## REGRESSION FIXES: +* The bug fix Debian Bug#941129 was incomplete and caused + + a regression in the default file locations, so that fetchmail was no longer + able to find it configuration files in some situations. + Reported by Cy Schubert. + + a regression under _FORTIFY_SOURCE where PATH_MAX > minimal _POSIX_PATH_MAX. -------------------------------------------------------------------------------- @@ -137,9 +137,16 @@ void envquery(int argc, char **argv) * without changing behaviour. */ { - static char _home_abs[_POSIX_PATH_MAX]; - char *tmp = realpath(home, _home_abs); - if (tmp) home = _home_abs; + static char *_home_abs; + char *tmp; + if (_home_abs) free(_home_abs), _home_abs = 0; + tmp = realpath(home, NULL); + if (tmp) { + home = _home_abs = tmp; + } else { + report(stderr, GT_("Cannot find absolute path for user's home directory.\n")); + exit(PS_UNDEFINED); + } } /* compute fetchmail's home directory */ @@ -154,9 +161,16 @@ void envquery(int argc, char **argv) * This is to fix Debian Bug#941129 by Alex Andreotti. */ { - static char _fmhome_abs[_POSIX_PATH_MAX]; - char *tmp = realpath(fmhome, _fmhome_abs); - if (tmp) fmhome = _fmhome_abs; + static char *_fmhome_abs; + char *tmp; + if (_fmhome_abs) free(_fmhome_abs), _fmhome_abs = 0; + tmp = realpath(fmhome, NULL); + if (tmp) { + fmhome = _fmhome_abs = tmp; + } else { + report(stderr, GT_("Cannot find absolute path for fetchmail's home directory.\n")); + exit(PS_UNDEFINED); + } } #define RCFILE_NAME "fetchmailrc" |