(fix) properly null-terminate IS8601-formatted dates (fixes #3539)

pull/203/head
Ludovic Marcotte 2016-03-13 14:25:09 -04:00
parent beb4af9f9f
commit 9a4d2c6b1c
2 changed files with 13 additions and 11 deletions

1
NEWS
View File

@ -12,6 +12,7 @@ Bug fixes
- [web] fixed display of ghosts when dragging events
- [web] fixed management of mail labels in Preferences module
- [web] respect super user privileges to create in any calendar and addressbook
- [web] properly null-terminate IS8601-formatted dates (#3539)
3.0.2 (2016-03-04)
------------------

View File

@ -116,31 +116,32 @@ static NSString *rfc822Months[] = {@"", @"Jan", @"Feb", @"Mar", @"Apr",
- (NSString *) iso8601DateString
{
char buf[22];
int timeZoneHourShift, timeZoneMinuteShift, tzSeconds;
NSNumber *day, *month, *year, *hour, *minute;
int timeZoneHourShift, timeZoneMinuteShift, tzSeconds;
char buf[23];
day = [NSNumber numberWithInt: [self dayOfMonth]];
month = [NSNumber numberWithInt: [self monthOfYear]];
year = [NSNumber numberWithInt: [self yearOfCommonEra]];
hour = [NSNumber numberWithInt: [self hourOfDay]];
minute = [NSNumber numberWithInt: [self minuteOfHour]];
memset(buf, 0, 23);
tzSeconds = [[self timeZone] secondsFromGMT];
timeZoneHourShift = (tzSeconds / 3600);
tzSeconds -= timeZoneHourShift * 3600;
timeZoneMinuteShift = tzSeconds / 60;
sprintf(buf, "%04d-%02d-%02dT%02d:%02d%+.2d:%02d",
[year intValue],
[month intValue],
[day intValue],
[hour intValue],
[minute intValue],
timeZoneHourShift,
timeZoneMinuteShift);
snprintf(buf, 23, "%04d-%02d-%02dT%02d:%02d%+.2d:%02d",
[year intValue],
[month intValue],
[day intValue],
[hour intValue],
[minute intValue],
timeZoneHourShift,
timeZoneMinuteShift);
return [NSString stringWithCString:buf];
return [NSString stringWithCString: buf];
}
#define secondsOfDistantFuture 1073741823.0