From c2e139ef53ec7bc5cbacb0ee667513b4799358ee Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 30 Nov 2017 17:17:28 -0500 Subject: [PATCH] Replace realpath with readlink * Appears to be more modern and Debian Stretch requires it. --- src/tz.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/tz.cpp b/src/tz.cpp index 143e902..0c333a9 100644 --- a/src/tz.cpp +++ b/src/tz.cpp @@ -337,11 +337,11 @@ discover_tz_dir() if (!(lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0)) throw runtime_error("discover_tz_dir failed\n"); string result; - char rp[PATH_MAX]; - if (realpath(timezone, rp)) + char rp[PATH_MAX+1] = {}; + if (readlink(timezone, rp, sizeof(rp)-1) > 0) result = string(rp); else - throw system_error(errno, system_category(), "realpath() failed"); + throw system_error(errno, system_category(), "readlink() failed"); auto i = result.find("zoneinfo"); if (i == string::npos) throw runtime_error("discover_tz_dir failed to find zoneinfo\n"); @@ -3652,11 +3652,11 @@ tzdb::current_zone() const if (lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0) { using namespace std; string result; - char rp[PATH_MAX]; - if (realpath(timezone, rp)) + char rp[PATH_MAX+1] = {}; + if (readlink(timezone, rp, sizeof(rp)-1) > 0) result = string(rp); else - throw system_error(errno, system_category(), "realpath() failed"); + throw system_error(errno, system_category(), "readlink() failed"); const size_t pos = result.find(tz_dir); if (pos != result.npos) @@ -3680,11 +3680,11 @@ tzdb::current_zone() const if (lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0) { using namespace std; string result; - char rp[PATH_MAX]; - if (realpath(timezone, rp)) + char rp[PATH_MAX+1] = {}; + if (readlink(timezone, rp, sizeof(rp)-1) > 0) result = string(rp); else - throw system_error(errno, system_category(), "realpath() failed"); + throw system_error(errno, system_category(), "readlink() failed"); const size_t pos = result.find(tz_dir); if (pos != result.npos)