From 03bca0ebd4fb1e6f62ac53a26ebe0793b2b293e6 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Wed, 6 Sep 2017 12:25:52 -0700 Subject: [PATCH] Modify GetSymLinkStr for platforms that return ERANGE when buffer is too small, like HP_UX; tweak field splitting in crc32 test-harness test, for platforms that separate cksum fields with tabs, like Solaris 10 & maybe earlier. --- src/fs/fspropcalc.cpp | 8 ++++++++ src/test-harness/tests/crc32.pm | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fs/fspropcalc.cpp b/src/fs/fspropcalc.cpp index dca9572..9f35e95 100644 --- a/src/fs/fspropcalc.cpp +++ b/src/fs/fspropcalc.cpp @@ -99,7 +99,15 @@ bool cFSPropCalc::GetSymLinkStr(const TSTRING& strName, cArchive& arch, size_t s #endif if(rtn == -1) + { + // Some OSes (like HP-UX) return ERANGE if buffer is too small. + // This is nonstandard but better than the usual truncate-and-say-you-succeeded + // + if(ERANGE == errno) + return GetSymLinkStr(strName, arch, size*2); + return false; + } //Sadly if buf isn't big enough readlink 'succeeds' by truncating the string, so the only // clue your buffer might be too small is if you maxed it out. So we try again, within reason. diff --git a/src/test-harness/tests/crc32.pm b/src/test-harness/tests/crc32.pm index c4bf82d..764eccf 100644 --- a/src/test-harness/tests/crc32.pm +++ b/src/test-harness/tests/crc32.pm @@ -34,8 +34,10 @@ sub run() { printf("%-30s", "-- $description"); # lets see if the system 'cksum' agree's with siggen's crc32 value + # Doing split with ' ' instead of / / because some flavors of cksum + # like to separate fields with tabs, as seen on Solaris 10. # - my ($crc32, undef) = split(/ /, `cksum $twtools::twrootdir/test`); + my ($crc32, undef) = split(' ', `cksum $twtools::twrootdir/test`); if ($crc32 eq "") { ++$twtools::twskippedtests;