From d45c22523e9d7d9f61f53c66911aed3cf84c6a62 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 23 Mar 2015 10:54:36 -0400 Subject: [PATCH] prevent potential freebusy lookup crashes during timezone changes with repetitive events --- NEWS | 1 + UI/MainUI/SOGoUserHomePage.m | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 88fccc564..322216415 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ Bug fixes - fixed EAS handling of Bcc in emails (#3138) - fixed Language-Region tags in Web interface (#3121) - properly fallback over EAS to UTF-8 and then Latin1 for messages w/o charset (#3103) + - prevent potential freebusy lookup crashes during timezone changes with repetitive events 2.2.16 (2015-02-12) ------------------- diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index 2a8415d70..c6223e656 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -155,6 +155,7 @@ delta = [[currentDate timeZoneDetail] timeZoneSecondsFromGMT] - [[startDate timeZoneDetail] timeZoneSecondsFromGMT]; startInterval += (delta/60/15); + startInterval = (startInterval < -4 ? -4 : startInterval); currentDate = [record objectForKey: @"endDate"]; if ([currentDate earlierDate: endDate] == endDate) @@ -165,6 +166,8 @@ delta = [[currentDate timeZoneDetail] timeZoneSecondsFromGMT] - [[startDate timeZoneDetail] timeZoneSecondsFromGMT]; endInterval += (delta/60/15); + endInterval = (endInterval < 0 ? 0 : endInterval); + endInterval = (endInterval > itemCount+4 ? itemCount+4 : endInterval); // Update bit string representation // If the user is a resource with restristed amount of bookings, keep the sum of overlapping events @@ -230,7 +233,7 @@ intervals = interval / intervalSeconds + 8; // Build a bit string representation of the freebusy data for the period - freeBusyItems = NSZoneCalloc (NULL, intervals, sizeof (int)); + freeBusyItems = calloc(intervals, sizeof (unsigned int)); [self _fillFreeBusyItems: (freeBusyItems+4) count: (intervals-4) withRecords: [fb fetchFreeBusyInfosFrom: start to: end forContact: uid] @@ -243,7 +246,7 @@ { [freeBusy addObject: [NSString stringWithFormat: @"%d", *(freeBusyItems + count)]]; } - NSZoneFree (NULL, freeBusyItems); + free(freeBusyItems); // Return a NSString representation return [freeBusy componentsJoinedByString: @","];