From e897424fa4bf43005c5c5e855a1f239ea2bd7f61 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 24 Apr 2013 14:21:33 +0200 Subject: [PATCH] Resolves: rhbz#918079 libcmis::sha1() can return digests with fewer than 40 hexadecimal digits --- ...-918079-always-return-40-hexa-digits.patch | 55 +++++++++++++++++++ libcmis.spec | 8 ++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 0001-rhbz-918079-always-return-40-hexa-digits.patch diff --git a/0001-rhbz-918079-always-return-40-hexa-digits.patch b/0001-rhbz-918079-always-return-40-hexa-digits.patch new file mode 100644 index 0000000..706d23c --- /dev/null +++ b/0001-rhbz-918079-always-return-40-hexa-digits.patch @@ -0,0 +1,55 @@ +From 264824628f58a1668b54252babb1add4d3c7eb79 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Mon, 8 Apr 2013 14:07:23 +0200 +Subject: [PATCH 1/3] rhbz#918079 always return 40 hexa digits (cherry picked + from commit 8e66145d204f7d053549b7cc28aef6863cfd38c8) + +--- + src/libcmis/test-xmlutils.cxx | 12 ++++++++++-- + src/libcmis/xml-utils.cxx | 6 +++++- + 2 files changed, 15 insertions(+), 3 deletions(-) + +diff --git a/src/libcmis/test-xmlutils.cxx b/src/libcmis/test-xmlutils.cxx +index dd5082f..0e527ad 100644 +--- a/src/libcmis/test-xmlutils.cxx ++++ b/src/libcmis/test-xmlutils.cxx +@@ -431,8 +431,16 @@ void XmlTest::propertyIntegerAsXmlTest( ) + + void XmlTest::sha1Test( ) + { +- string actual = libcmis::sha1( "Hello" ); +- CPPUNIT_ASSERT_EQUAL( string( "f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0" ), actual ); ++ { ++ string actual = libcmis::sha1( "Hello" ); ++ CPPUNIT_ASSERT_EQUAL( string( "f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0" ), actual ); ++ } ++ ++ { ++ // check correct width ++ string actual = libcmis::sha1( "35969137" ); ++ CPPUNIT_ASSERT_EQUAL( string( "0d93546909cfeb5c00089202104df3980000ec9f" ), actual ); ++ } + } + + CPPUNIT_TEST_SUITE_REGISTRATION( XmlTest ); +diff --git a/src/libcmis/xml-utils.cxx b/src/libcmis/xml-utils.cxx +index dddfafa..645fbcf 100644 +--- a/src/libcmis/xml-utils.cxx ++++ b/src/libcmis/xml-utils.cxx +@@ -498,8 +498,12 @@ namespace libcmis + sha1.get_digest( digest ); + + stringstream out; ++ // Setup writing mode. Every number must produce eight ++ // hexadecimal digits, including possible leading 0s, or we get ++ // less than 40 digits as result. ++ out << hex << setfill('0') << right; + for ( int i = 0; i < 5; ++i ) +- out << hex << digest[i]; ++ out << setw(8) << digest[i]; + return out.str(); + } + +-- +1.8.1.4 + diff --git a/libcmis.spec b/libcmis.spec index ed90ffc..390a9d5 100644 --- a/libcmis.spec +++ b/libcmis.spec @@ -2,7 +2,7 @@ Name: libcmis Version: 0.3.1 -Release: 4%{?dist} +Release: 5%{?dist} Summary: A C++ client library for the CMIS interface Group: System Environment/Libraries @@ -16,6 +16,7 @@ BuildRequires: libxml2-devel BuildRequires: xmlto Patch0: 0001-libcmis-c-handle-possible-bad-allocations.patch +Patch1: 0001-rhbz-918079-always-return-40-hexa-digits.patch %description LibCMIS is a C++ client library for the CMIS interface. This allows C++ @@ -43,6 +44,7 @@ command line. %prep %setup -q %patch0 -p1 +%patch1 -p1 %build @@ -85,6 +87,10 @@ rm -f %{buildroot}/%{_libdir}/*.la %changelog +* Wed Apr 24 2013 David Tardon - 0.3.1-5 +- Resolves: rhbz#918079 libcmis::sha1() can return digests with fewer + than 40 hexadecimal digits + * Mon Apr 08 2013 David Tardon - 0.3.1-4 - Resolves: rhbz#918044 memory leaks on exception path in C wrapper