Skip to content

Commit

Permalink
Merge pull request #79 from jcaille/master
Browse files Browse the repository at this point in the history
Using non-reserved keywords in C++ and explicit casting of pointers
  • Loading branch information
hpique committed May 27, 2014
2 parents 9571b15 + 78aa74d commit b3617c1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions RMStore/Optional/RMAppReceipt.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@

static int RMASN1ReadInteger(const uint8_t **pp, long omax)
{
int tag, class;
int tag, asn1Class;
long length;
int value = 0;
ASN1_get_object(pp, &length, &tag, &class, omax);
ASN1_get_object(pp, &length, &tag, &asn1Class, omax);
if (tag == V_ASN1_INTEGER)
{
for (int i = 0; i < length; i++)
Expand All @@ -65,10 +65,10 @@ static int RMASN1ReadInteger(const uint8_t **pp, long omax)

static NSData* RMASN1ReadOctectString(const uint8_t **pp, long omax)
{
int tag, class;
int tag, asn1Class;
long length;
NSData *data = nil;
ASN1_get_object(pp, &length, &tag, &class, omax);
ASN1_get_object(pp, &length, &tag, &asn1Class, omax);
if (tag == V_ASN1_OCTET_STRING)
{
data = [NSData dataWithBytes:*pp length:length];
Expand All @@ -79,10 +79,10 @@ static int RMASN1ReadInteger(const uint8_t **pp, long omax)

static NSString* RMASN1ReadString(const uint8_t **pp, long omax, int expectedTag, NSStringEncoding encoding)
{
int tag, class;
int tag, asn1Class;
long length;
NSString *value = nil;
ASN1_get_object(pp, &length, &tag, &class, omax);
ASN1_get_object(pp, &length, &tag, &asn1Class, omax);
if (tag == expectedTag)
{
value = [[NSString alloc] initWithBytes:*pp length:length encoding:encoding];
Expand Down Expand Up @@ -110,8 +110,9 @@ - (id)initWithASN1Data:(NSData*)asn1Data
if (self = [super init])
{
NSMutableArray *purchases = [NSMutableArray array];
[RMAppReceipt enumerateASN1Attributes:asn1Data.bytes length:asn1Data.length usingBlock:^(NSData *data, int type) {
const uint8_t *s = data.bytes;
// Explicit casting to avoid errors when compiling as Objective-C++
[RMAppReceipt enumerateASN1Attributes:(const uint8_t*)asn1Data.bytes length:asn1Data.length usingBlock:^(NSData *data, int type) {
const uint8_t *s = (const uint8_t*)data.bytes;
const NSUInteger length = data.length;
switch (type)
{
Expand Down Expand Up @@ -190,7 +191,7 @@ - (BOOL)verifyReceiptHash
[data appendData:self.bundleIdentifierData];

NSMutableData *expectedHash = [NSMutableData dataWithLength:SHA_DIGEST_LENGTH];
SHA1(data.bytes, data.length, expectedHash.mutableBytes);
SHA1((const uint8_t*)data.bytes, data.length, (uint8_t*)expectedHash.mutableBytes); // Explicit casting to avoid errors when compiling as Objective-C++

return [expectedHash isEqualToData:self.hash];
}
Expand Down Expand Up @@ -328,8 +329,9 @@ - (id)initWithASN1Data:(NSData*)asn1Data
{
if (self = [super init])
{
[RMAppReceipt enumerateASN1Attributes:asn1Data.bytes length:asn1Data.length usingBlock:^(NSData *data, int type) {
const uint8_t *p = data.bytes;
// Explicit casting to avoid errors when compiling as Objective-C++
[RMAppReceipt enumerateASN1Attributes:(const uint8_t*)asn1Data.bytes length:asn1Data.length usingBlock:^(NSData *data, int type) {
const uint8_t *p = (const uint8_t*)data.bytes;
const NSUInteger length = data.length;
switch (type)
{
Expand Down

0 comments on commit b3617c1

Please sign in to comment.