From f75949692ef3adc4a9b42a7f8fe6ffdf0fefd5a1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 24 Jul 2009 19:47:15 +0000 Subject: * Extend mssql name string size checking to create/update folder --- OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index d68ac39..3bf4d04 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs @@ -227,13 +227,19 @@ namespace OpenSim.Data.MSSQL string sql = @"INSERT INTO inventoryfolders ([folderID], [agentID], [parentFolderID], [folderName], [type], [version]) VALUES (@folderID, @agentID, @parentFolderID, @folderName, @type, @version);"; - + string folderName = folder.Name; + if (folderName.Length > 64) + { + folderName = folderName.Substring(0, 64); + m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on add"); + } + using (AutoClosingSqlCommand command = database.Query(sql)) { command.Parameters.Add(database.CreateParameter("folderID", folder.ID)); command.Parameters.Add(database.CreateParameter("agentID", folder.Owner)); command.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID)); - command.Parameters.Add(database.CreateParameter("folderName", folder.Name)); + command.Parameters.Add(database.CreateParameter("folderName", folderName)); command.Parameters.Add(database.CreateParameter("type", folder.Type)); command.Parameters.Add(database.CreateParameter("version", folder.Version)); @@ -262,15 +268,24 @@ namespace OpenSim.Data.MSSQL type = @type, version = @version WHERE folderID = @keyFolderID"; + + string folderName = folder.Name; + if (folderName.Length > 64) + { + folderName = folderName.Substring(0, 64); + m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on update"); + } + using (AutoClosingSqlCommand command = database.Query(sql)) { command.Parameters.Add(database.CreateParameter("folderID", folder.ID)); command.Parameters.Add(database.CreateParameter("agentID", folder.Owner)); command.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID)); - command.Parameters.Add(database.CreateParameter("folderName", folder.Name)); + command.Parameters.Add(database.CreateParameter("folderName", folderName)); command.Parameters.Add(database.CreateParameter("type", folder.Type)); command.Parameters.Add(database.CreateParameter("version", folder.Version)); command.Parameters.Add(database.CreateParameter("@keyFolderID", folder.ID)); + try { command.ExecuteNonQuery(); -- cgit v1.1