From 1e06389361f5b4458357499747cde2078020a535 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Sat, 26 Mar 2016 16:08:04 -0700 Subject: [PATCH] Fix SHA hashes when using OpenSSL impl; build fix for SkyOS 5.0 which doesn't have syslog(). --- ChangeLog | 4 ++-- src/fco/signature.cpp | 41 +++++++++++++++++++++++++++++++++--- src/tripwire/syslog_trip.cpp | 2 ++ tripwire.spec | 4 ++-- 4 files changed, 44 insertions(+), 7 deletions(-) mode change 100644 => 100755 src/fco/signature.cpp diff --git a/ChangeLog b/ChangeLog index ac14548..12ea228 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,10 +4,10 @@ (see http://www.linuxfromscratch.org/blfs/view/svn/postlfs/tripwire.html ) * Absorb fixes from FreeBSD ports patchset (see http://svnweb.freebsd.org/ports/head/security/tripwire/ ) - * Fix handling of SHA hashes when not built to use OpenSSL implementation + * Fix handling of SHA hashes (with and without OpenSSL hash impl.) * Update GNU config.guess & config.sub to current versions * Compilation fixes for assorted platforms - (Mac OS X, OpenBSD, OpenSolaris, Cygwin, Minix 3.x, GNU/Hurd, Haiku, Syllable) + (Mac OS X, OpenBSD, OpenSolaris, Cygwin, Minix 3.x, GNU/Hurd, Haiku, Syllable, SkyOS) * Added script to bump buildys file timestaps, to fix spurious aclocal/automake errors on a fresh clone/untar/etc. diff --git a/src/fco/signature.cpp b/src/fco/signature.cpp old mode 100644 new mode 100755 index c078d9a..66f1aba --- a/src/fco/signature.cpp +++ b/src/fco/signature.cpp @@ -642,7 +642,6 @@ TSTRING cSHASignature::AsString(void) const ret.append(ps_signature); #endif return ret; - //return ret; } TSTRING cSHASignature::AsStringHex() const @@ -664,6 +663,43 @@ TSTRING cSHASignature::AsStringHex() const return ret; } +/////////////////////////////////////////////////////////////////////////////// +// Copy -- Copies a new sig value from a base pointer +void cSHASignature::Copy(const iFCOProp* rhs) +{ + ASSERT(GetType() == rhs->GetType()); + for (int i = 0; i(rhs))->sha_digest)[i]; +} + +/////////////////////////////////////////////////////////////////////////////// +// Serializer Implementation: Read and Write +void cSHASignature::Read (iSerializer* pSerializer, int32 version) +{ + if (version > Version()) + ThrowAndAssert(eSerializerVersionMismatch(_T("SHA Read"))); + + for (int i = 0; i < SIG_UINT32_SIZE; ++i) + pSerializer->ReadInt32((int32&)sha_digest[i]); +} + +void cSHASignature::Write(iSerializer* pSerializer) const +{ + for (int i = 0; i < SIG_UINT32_SIZE; ++i) + pSerializer->WriteInt32(sha_digest[i]); +} + +/////////////////////////////////////////////////////////////////////////////// +// IsEqual -- Tests for equality, given a base pointer (iSignature) +bool cSHASignature::IsEqual(const iSignature& rhs) const +{ + if (this == &rhs) + return true; + else { + return (memcmp(sha_digest, ((cSHASignature&)rhs).sha_digest, SIG_UINT32_SIZE * sizeof(uint32)) == 0); + } +} + #else // HAVE_OPENSSL_SHA_H TSTRING cSHASignature::AsString(void) const @@ -704,7 +740,6 @@ TSTRING cSHASignature::AsStringHex() const return ret; } -#endif /////////////////////////////////////////////////////////////////////////////// // Copy -- Copies a new sig value from a base pointer @@ -742,7 +777,7 @@ bool cSHASignature::IsEqual(const iSignature& rhs) const return (memcmp(mSHAInfo.digest, ((cSHASignature&)rhs).mSHAInfo.digest, SIG_UINT32_SIZE * sizeof(uint32)) == 0); } } - +#endif /////////////////////////////////////////////////////////////////////////////// // class cHAVALSignature -- /////////////////////////////////////////////////////////////////////////////// diff --git a/src/tripwire/syslog_trip.cpp b/src/tripwire/syslog_trip.cpp index ed0b49f..dab273a 100644 --- a/src/tripwire/syslog_trip.cpp +++ b/src/tripwire/syslog_trip.cpp @@ -91,9 +91,11 @@ void cSyslog::Log(const TCHAR* programName, cSyslog::LogType logType, const TCHA const char* msg = message; #endif +#ifndef SKYOS // Handle an oddball OS that has syslog.h but doesn't implement the calls. openlog(ident, LOG_PID, LOG_USER); syslog(LOG_NOTICE, "%s", msg); closelog(); +#endif #elif SUPPORTS_EVENTLOG diff --git a/tripwire.spec b/tripwire.spec index d50969a..2b91a7d 100644 --- a/tripwire.spec +++ b/tripwire.spec @@ -149,9 +149,9 @@ post - Bumping version to 2.4.3.0 - Compilation fixes for gcc 4.7+ and LLVM/clang (see http://www.linuxfromscratch.org/blfs/view/svn/postlfs/tripwire.html ) - Absorb fixes from FreeBSD ports patchset (see http://svnweb.freebsd.org/ports/head/security/tripwire/ ) -- Fix handling of SHA hashes when not using OpenSSL impl +- Fix handling of SHA hashes (with and without OpenSSL hash impl.) - Update GNU config.guess & config.sub to current versions -- Compilation fixes for assorted platforms (Mac OS X, OpenBSD, OpenSolaris, Cygwin, Minix 3.x, GNU/Hurd, Haiku, Syllable) +- Compilation fixes for assorted platforms (Mac OS X, OpenBSD, OpenSolaris, Cygwin, Minix 3.x, GNU/Hurd, Haiku, Syllable, SkyOS) - Added script to bump buildys file timestaps, to fix spurious aclocal/automake errors on a fresh clone/untar/etc. * Mon Nov 21 2011 Stephane Dudzinski 2.4.2.2