(fix) improve EAS parameters parsing (fixes #4003)

pull/278/head
Ludovic Marcotte 2017-02-01 13:03:27 -05:00
parent 94a94e3c2a
commit 4bb5d15cfa
2 changed files with 17 additions and 0 deletions

View File

@ -151,6 +151,10 @@ static NSArray *easCommandParameters = nil;
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)];
@ -199,6 +203,11 @@ static NSArray *easCommandParameters = nil;
// 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)

View File

@ -3971,6 +3971,14 @@ void handle_eas_terminate(int signum)
// 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"];