[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone.issue-182: 555bc063aee165fc7
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone.issue-182: 555bc063aee165fc7500cc68df5d818dcaf30913 |
Date: |
Mon, 23 Apr 2012 22:13:19 +0200 (CEST) |
revision: 555bc063aee165fc7500cc68df5d818dcaf30913
suspend: net.venge.monotone.issue-182
date: 2012-04-23T19:56:38
author: address@hidden
branch: net.venge.monotone.issue-182
changelog:
Make monotone work with newer Botan versions (1.9.4 and above, including
Botan's stable branch 1.10.x).
src/gzip.{cc,hh}: Use Botan exceptions that base on std::invalid_argument
(from Botan 1.9.11 on), to be more in line with Botan's exception handling.
In Gzip_Decompression::write(): return without acting in case the data
passed has a zero length. Looks like older Botans didn't ever do that.
src/key_store.cc: when calling load_key(), catch Botan::Invalid_Argument
exceptions instead of Botan::Excetion, which isn't a base class of the
former, anymore. For Botan 1.9.11, we can be even more specific and catch
the new Passphrase_Required exception. In decrypt_rsa(), catch on
std::exception, to cover both base types of Botan exceptions.
src/packet.{cc,hh}: simplify the Dummy_UI class for Botan 1.9.11 and newer,
make Passphrase_Required a simply typedef for runtime_error, instead of
deriving from Botan::Exception (note that other exceptions, like
Botan::Decoding_Error are derived from Botan::Invalid_Arguments and thus
std::invalid_argument).
src/transforms.cc: add Botan::Invalid_Argument to the list of exceptions
that may indicate data corruption.
src/monotone.cc: improve, correct, unify and comment the runtime Botan
version checks.
manifest:
format_version "1"
new_manifest [bf8f3dcbde671ddac4001f67ae06c78c69c3745a]
old_revision [dc0bcdde415716d2a6cd751b2fb5315d0daec265]
patch "src/gzip.cc"
from [bab290412cff6031b2d3bf9d1439a08499d39640]
to [9da41f6820cdf39707b22c716e3682e0fa0fd745]
patch "src/gzip.hh"
from [f462dfc1df71ae1e9a8203606fd29d9e0eda9b2a]
to [aff9da63bb22366bccf69c2d75ee7790406d2455]
patch "src/key_store.cc"
from [1b1f1a989c21ee0dc69c540783ffb1fe4bceabf5]
to [b7859345f7c665914d16357409bdff24a48b7996]
patch "src/monotone.cc"
from [2c5f57762bc687a90f75e732f39d2181fc50bd6d]
to [764bc9ca406b41d21efd552a0d810bc2849e0588]
patch "src/packet.cc"
from [6f6739c4756933843a2d865dc6790de9013626b7]
to [571ff6eae1d269a146da74f2730b70376957d3bb]
patch "src/packet.hh"
from [6c7d90e0bd9abe1e2e97da8ed40808fe438ea34b]
to [9c43d30145f0292d6ceda5e717e366fdead5a4d6]
patch "src/transforms.cc"
from [789e01bbff42020d04d8dba8f6b97588fbe4ca3d]
to [b99278ffe95c0081bf4986bc74d3699c37a52948]
============================================================
--- src/monotone.cc 2c5f57762bc687a90f75e732f39d2181fc50bd6d
+++ src/monotone.cc 764bc9ca406b41d21efd552a0d810bc2849e0588
@@ -156,32 +156,53 @@ cpp_main(int argc, char ** argv)
E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,7,14), origin::system,
F("monotone does not support Botan 1.7.14"));
-#if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,6)
+ // In Botan 1.9.9, the DataSink_Stream cannot be instantiated per
+ // se. As 1.10.1 is already out, let's simply disable support for
+ // that specific (testing) version of botan.
+ E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,9,9), origin::system,
+ F("monotone does not support Botan 1.9.9"));
+
+#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,7)
+ // motonote binary compiled against botan younger than 1.7.7
E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,6,3), origin::system,
F("this monotone binary requires Botan 1.6.3 or newer"));
- E(linked_botan_version <= BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
- F("this monotone binary does not work with Botan newer than 1.7.6"));
-#elif BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,22)
- E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
+ E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
+ F("this monotone binary does not work with Botan 1.7.7 or newer"));
+
+#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,22)
+ // motonote binary compiled against botan 1.7.7 - 1.7.21
+ E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
F("this monotone binary requires Botan 1.7.7 or newer"));
- // While compiling against 1.7.22 or newer is recommended, because
- // it enables new features of Botan, the monotone binary compiled
- // against Botan 1.7.21 and before should still work with newer Botan
- // versions, including all of the stable branch 1.8.x.
- E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
- F("this monotone binary does not work with Botan 1.9.x"));
-#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
- E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
+ // While compiling against 1.7.22 or newer is recommended, because it
+ // enables new features of Botan, the monotone binary compiled against
+ // Botan 1.7.21 and before should still work with newer Botan version,
+ // including all of the stable branch 1.8.x, up to and including
+ // 1.9.3.
+ E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
+ F("this monotone binary does not work with Botan 1.9.4 or newer"));
+
+#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
+ // motonote binary compiled against botan 1.7.22 - 1.9.3
+ E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
F("this monotone binary requires Botan 1.7.22 or newer"));
- E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
- F("this monotone binary does not work with Botan 1.9.x"));
+ E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
+ F("this monotone binary does not work with Botan 1.9.4 or newer"));
+
+#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
+ // motonote binary compiled against botan 1.9.4 - 1.9.10
+#pragma message ( "The resulting monotone binary won't be able to run with any stable release of botan." )
+ E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
+ F("this monotone binary requires Botan 1.9.4 or newer"));
+ E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
+ F("this monotone binary does not work with Botan 1.9.11 or newer"));
+
#else
- E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
+ // motonote binary compiled against botan 1.9.11 and newer
+ E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
F("this monotone binary requires Botan 1.9.11 or newer"));
- E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,11,0), origin::system,
- F("this monotone binary does not work with Botan 1.11.x"));
#endif
+
app_state app;
try
{
============================================================
--- src/packet.cc 6f6739c4756933843a2d865dc6790de9013626b7
+++ src/packet.cc 571ff6eae1d269a146da74f2730b70376957d3bb
@@ -466,11 +466,13 @@ read_packets(istream & in, packet_consum
return count;
}
+// Dummy User_Interface implementation for Botan
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
-std::string Dummy_UI::get_passphrase(const std::string&,
- const std::string&,
- Botan::User_Interface::UI_Result&) const {
- throw Passphrase_Required();
+std::string
+Dummy_UI::get_passphrase(const std::string &, const std::string &,
+ Botan::User_Interface::UI_Result&) const
+{
+ throw Passphrase_Required("Passphrase required");
}
#endif
============================================================
--- src/packet.hh 6c7d90e0bd9abe1e2e97da8ed40808fe438ea34b
+++ src/packet.hh 9c43d30145f0292d6ceda5e717e366fdead5a4d6
@@ -10,6 +10,10 @@
#ifndef __PACKET_HH__
#define __PACKET_HH__
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
+#include <botan/ui.h>
+#endif
+
#include "vocab.hh"
struct cert;
@@ -85,21 +89,18 @@ size_t read_packets(std::istream & in, p
size_t read_packets(std::istream & in, packet_consumer & cons);
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
-// work around botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
-#include <botan/ui.h>
+// A helper class implementing Botan::User_Interface - which doesn't really
+// interface with the user, but provides the necessary plumbing for Botan.
+//
+// See Botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
+typedef std::runtime_error Passphrase_Required;
+
class Dummy_UI : public Botan::User_Interface
{
public:
- virtual std::string get_passphrase(const std::string&,
- const std::string&,
- Botan::User_Interface::UI_Result&) const;
+ virtual std::string get_passphrase(const std::string &, const std::string &,
+ Botan::User_Interface::UI_Result &) const;
};
-class Passphrase_Required : public Botan::Exception {
-public:
- Passphrase_Required(const std::string& m = "Passphrase required") :
- Botan::Exception(m)
- {}
-};
#endif
#endif
============================================================
--- src/transforms.cc 789e01bbff42020d04d8dba8f6b97588fbe4ca3d
+++ src/transforms.cc b99278ffe95c0081bf4986bc74d3699c37a52948
@@ -62,6 +62,7 @@ error_in_transform(std::exception & e, o
if (typeid(e) == typeid(Botan::Encoding_Error)
|| typeid(e) == typeid(Botan::Decoding_Error)
|| typeid(e) == typeid(Botan::Stream_IO_Error)
+ || typeid(e) == typeid(Botan::Invalid_Argument)
|| typeid(e) == typeid(Botan::Integrity_Failure))
{
// clean up the what() string a little: throw away the
============================================================
--- src/key_store.cc 1b1f1a989c21ee0dc69c540783ffb1fe4bceabf5
+++ src/key_store.cc b7859345f7c665914d16357409bdff24a48b7996
@@ -582,6 +582,8 @@ key_store_state::decrypt_private_key(key
}
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
catch (Passphrase_Required & e)
+#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
+ catch (Botan::Invalid_Argument & e)
#else
catch (Botan::Exception & e)
#endif
@@ -611,13 +613,18 @@ key_store_state::decrypt_private_key(key
{
Botan::DataSource_Memory ds(kp.priv());
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
- pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), phrase()));
+ pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(),
+ phrase()));
#else
pkcs8_key.reset(Botan::PKCS8::load_key(ds, phrase()));
#endif
break;
}
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
+ catch (Botan::Invalid_Argument)
+#else
catch (Botan::Exception & e)
+#endif
{
cycles++;
L(FL("decrypt_private_key: failure %d to load encrypted key: %s")
@@ -828,10 +835,14 @@ key_store::decrypt_rsa(key_id const & id
plaintext = string(reinterpret_cast<char const*>(plain.begin()),
plain.size());
}
- catch (Botan::Exception & ex)
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
+ catch (std::exception & e)
+#else
+ catch (Botan::Exception & e)
+#endif
{
E(false, ciphertext.made_from,
- F("Botan error decrypting data: '%s'") % ex.what());
+ F("Botan error decrypting data: '%s'") % e.what());
}
}
@@ -1063,7 +1074,11 @@ key_store_state::migrate_old_key_pair
#endif
break;
}
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
+ catch (Botan::Invalid_Argument & e)
+#else
catch (Botan::Exception & e)
+#endif
{
L(FL("migrate_old_key_pair: failure %d to load old private key: %s")
% cycles % e.what());
============================================================
--- src/gzip.cc bab290412cff6031b2d3bf9d1439a08499d39640
+++ src/gzip.cc 9da41f6820cdf39707b22c716e3682e0fa0fd745
@@ -110,7 +110,7 @@ Gzip_Compression::Gzip_Compression(u32bi
if(deflateInit2(&(zlib->stream), level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK)
{
delete zlib; zlib = 0;
- throw Exception("Gzip_Compression: Memory allocation error");
+ throw Memory_Exhaustion();
}
}
@@ -152,7 +152,7 @@ void Gzip_Compression::write(const byte
zlib->stream.avail_out = buffer.size();
int rc = deflate(&(zlib->stream), Z_NO_FLUSH);
if (rc != Z_OK && rc != Z_STREAM_END)
- throw Exception("Internal error in Gzip_Compression deflate.");
+ throw Invalid_State("Internal error in Gzip_Compression deflate.");
send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
}
}
@@ -172,7 +172,7 @@ void Gzip_Compression::end_msg()
zlib->stream.avail_out = buffer.size();
rc = deflate(&(zlib->stream), Z_FINISH);
if (rc != Z_OK && rc != Z_STREAM_END)
- throw Exception("Internal error in Gzip_Compression finishing deflate.");
+ throw Invalid_State("Internal error in Gzip_Compression finishing deflate.");
send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
}
@@ -228,7 +228,7 @@ Gzip_Decompression::Gzip_Decompression()
no_writes(true), pipe(new Hash_Filter("CRC32")), footer(0)
{
if (DEFAULT_BUFFERSIZE < sizeof(GZIP::GZIP_HEADER))
- throw Exception("DEFAULT_BUFFERSIZE is too small");
+ throw Decoding_Error("DEFAULT_BUFFERSIZE is too small");
zlib = new Zlib_Stream;
@@ -237,7 +237,7 @@ Gzip_Decompression::Gzip_Decompression()
if(inflateInit2(&(zlib->stream), -15) != Z_OK)
{
delete zlib; zlib = 0;
- throw Exception("Gzip_Decompression: Memory allocation error");
+ throw Memory_Exhaustion();
}
}
@@ -256,7 +256,7 @@ void Gzip_Decompression::start_msg()
void Gzip_Decompression::start_msg()
{
if (!no_writes)
- throw Exception("Gzip_Decompression: start_msg after already writing");
+ throw Decoding_Error("Gzip_Decompression: start_msg after already writing");
pipe.start_msg();
datacount = 0;
@@ -277,10 +277,11 @@ void Gzip_Decompression::write(const byt
u32bit eat_len = eat_footer(input, length);
input += eat_len;
length -= eat_len;
- if (length == 0)
- return;
}
+ if (length == 0)
+ return;
+
// Check the gzip header
if (pos < sizeof(GZIP::GZIP_HEADER))
{
@@ -317,8 +318,8 @@ void Gzip_Decompression::write(const byt
if(rc == Z_NEED_DICT)
throw Decoding_Error("Gzip_Decompression: Need preset dictionary");
if(rc == Z_MEM_ERROR)
- throw Exception("Gzip_Decompression: Memory allocation error");
- throw Exception("Gzip_Decompression: Unknown decompress error");
+ throw Memory_Exhaustion();
+ throw Decoding_Error("Gzip_Decompression: Unknown decompress error");
}
send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
pipe.write(buffer.begin(), buffer.size() - zlib->stream.avail_out);
@@ -370,7 +371,7 @@ void Gzip_Decompression::check_footer()
void Gzip_Decompression::check_footer()
{
if (footer.size() != GZIP::FOOTER_LENGTH)
- throw Exception("Gzip_Decompression: Error finalizing decompression");
+ throw Decoding_Error("Gzip_Decompression: Error finalizing decompression");
pipe.end_msg();
@@ -411,7 +412,7 @@ void Gzip_Decompression::end_msg()
// read, clear() will reset no_writes
if(no_writes) return;
- throw Exception("Gzip_Decompression: didn't find footer");
+ throw Decoding_Error("Gzip_Decompression: didn't find footer");
}
============================================================
--- src/gzip.hh f462dfc1df71ae1e9a8203606fd29d9e0eda9b2a
+++ src/gzip.hh aff9da63bb22366bccf69c2d75ee7790406d2455
@@ -13,6 +13,12 @@ namespace Botan {
namespace Botan {
+#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
+// Only 1.9.4 and newer export the Memory_Exception. Give this gzip
+// implementation something compatible to work with.
+typedef std::bad_alloc Memory_Exhaustion;
+#endif
+
namespace GZIP {
/* A basic header - we only need to set the IDs and compression method */
@@ -32,9 +38,9 @@ namespace GZIP {
}
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
- typedef size_t filter_length_t;
+typedef size_t filter_length_t;
#else
- typedef u32bit filter_length_t;
+typedef u32bit filter_length_t;
#endif
/*************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone.issue-182: 555bc063aee165fc7500cc68df5d818dcaf30913,
code <=