From 7f2d8449169481f1ec6ee5373bdfeef83c3434bc Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 22 Oct 2010 19:30:15 +0100
Subject: Implement guard against trying to load incompatible version IARs
---
.../Archiver/InventoryArchiveReadRequest.cs | 21 +++++++++++++++++++--
.../World/Archiver/ArchiveReadRequest.cs | 2 +-
2 files changed, 20 insertions(+), 3 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 2beea8e..5500557 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -51,6 +51,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// The maximum major version of archive that we can read. Minor versions shouldn't need a max number since version
+ /// bumps here should be compatible.
+ ///
+ public static int MAX_MAJOR_VERSION = 0;
+
protected TarArchiveReader archive;
private UserAccount m_userInfo;
@@ -476,8 +482,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data));
XElement archiveElement = doc.Element("archive");
- int.Parse(archiveElement.Attribute("major_version").Value);
- int.Parse(archiveElement.Attribute("minor_version").Value);
+ int majorVersion = int.Parse(archiveElement.Attribute("major_version").Value);
+ int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value);
+ string version = string.Format("{0}.{1}", majorVersion, minorVersion);
+
+ if (majorVersion > MAX_MAJOR_VERSION)
+ {
+ throw new Exception(
+ string.Format(
+ "The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below",
+ majorVersion, MAX_MAJOR_VERSION));
+ }
+
+ m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 087d3df..117b2fd 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
///
- /// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version
+ /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version
/// bumps here should be compatible.
///
public static int MAX_MAJOR_VERSION = 0;
--
cgit v1.1