Navigation Menu

Skip to content

Commit

Permalink
(fix) improve EAS parameters parsing (fixes #4003)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Feb 1, 2017
1 parent b412788 commit 50d8975
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ActiveSync/NSString+ActiveSync.m
Expand Up @@ -148,6 +148,10 @@ - (NSString *) protocolVersion
const char* qs_bytes;

queryString = [[components objectAtIndex: 0] dataByDecodingBase64];

if (![queryString length])
return nil;

qs_bytes = (const char*)[queryString bytes];

return [NSString stringWithFormat:@"%.1f", (float)((uint8_t)qs_bytes[0]/10)];
Expand Down Expand Up @@ -196,6 +200,11 @@ - (NSString *) _valueForParameter: (NSString *) theParameter

// Command code, 1 byte, ie.: cmd=
cmd_code = qs_bytes[1];

// Check whether the command code is within the known range.
if (cmd_code < 0 || cmd_code > 22)
return nil;

[components addObject: [NSString stringWithFormat: @"cmd=%@", [easCommandCodes objectAtIndex: cmd_code]]];

// Device ID length and Device ID (variable)
Expand Down
8 changes: 8 additions & 0 deletions ActiveSync/SOGoActiveSyncDispatcher.m
Expand Up @@ -3983,6 +3983,14 @@ - (NSException *) dispatchRequest: (id) theRequest

// Get the device ID, device type and "stash" them
deviceId = [[theRequest uri] deviceId];

if ([deviceId isEqualToString: @"Unknown"])
{
[(WOResponse *)theResponse setStatus: 500];
[self logWithFormat: @"EAS - No device id provided, ignoring request."];
return nil;
}

[context setObject: deviceId forKey: @"DeviceId"];
[context setObject: [[theRequest uri] deviceType] forKey: @"DeviceType"];
[context setObject: [[theRequest uri] attachmentName] forKey: @"AttachmentName"];
Expand Down

0 comments on commit 50d8975

Please sign in to comment.