Prevent a crash when someone tries to access /SOGo/Microsoft-Server-ActiveSync directly

pull/40/head
Ludovic Marcotte 2014-05-22 14:39:58 -04:00
parent cb9332f240
commit ab7780d617
1 changed files with 9 additions and 4 deletions

View File

@ -1705,6 +1705,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if (!folderTableURL) if (!folderTableURL)
{ {
user = [context activeUser]; user = [context activeUser];
if (![user loginInDomain])
return nil;
urlString = [[user domainDefaults] folderInfoURL]; urlString = [[user domainDefaults] folderInfoURL];
parts = [[urlString componentsSeparatedByString: @"/"] parts = [[urlString componentsSeparatedByString: @"/"]
mutableCopy]; mutableCopy];
@ -1714,7 +1718,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* If "OCSFolderInfoURL" is properly configured, we must have 5 /* If "OCSFolderInfoURL" is properly configured, we must have 5
parts in this url. */ parts in this url. */
ocFSTableName = [NSString stringWithFormat: @"sogo_cache_folder_%@", ocFSTableName = [NSString stringWithFormat: @"sogo_cache_folder_%@",
[[[context activeUser] loginInDomain] asCSSIdentifier]]; [[user loginInDomain] asCSSIdentifier]];
[parts replaceObjectAtIndex: 4 withObject: ocFSTableName]; [parts replaceObjectAtIndex: 4 withObject: ocFSTableName];
folderTableURL folderTableURL
= [NSURL URLWithString: [parts componentsJoinedByString: @"/"]]; = [NSURL URLWithString: [parts componentsJoinedByString: @"/"]];
@ -1742,9 +1746,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* FIXME: make use of [EOChannelAdaptor describeTableNames] instead */ /* FIXME: make use of [EOChannelAdaptor describeTableNames] instead */
tableName = [[folderTableURL path] lastPathComponent]; tableName = [[folderTableURL path] lastPathComponent];
if ([channel evaluateExpressionX: if (tableName &&
[NSString stringWithFormat: @"SELECT count(*) FROM %@", [channel evaluateExpressionX:
tableName]]) [NSString stringWithFormat: @"SELECT count(*) FROM %@",
tableName]])
{ {
queries = [channel specialQueries]; queries = [channel specialQueries];
query = [queries createSOGoCacheGCSFolderTableWithName: tableName]; query = [queries createSOGoCacheGCSFolderTableWithName: tableName];