From 97f968fb0d1ae06cf3d8d776ec291cab26e498fe Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 21 Oct 2014 00:36:30 -0400 Subject: [PATCH] Fix some mostly harmless warnings from LLVM static analysis --- Limelight/CryptoManager.m | 7 +++---- Limelight/HttpManager.m | 19 ++++--------------- Limelight/mkcert.c | 4 ++-- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Limelight/CryptoManager.m b/Limelight/CryptoManager.m index bd03953..c7ee7de 100644 --- a/Limelight/CryptoManager.m +++ b/Limelight/CryptoManager.m @@ -119,13 +119,12 @@ static NSData* p12 = nil; return NULL; } - int ret = -1; EVP_MD_CTX *mdctx = NULL; mdctx = EVP_MD_CTX_create(); - ret = EVP_DigestSignInit(mdctx, NULL, EVP_sha256(), NULL, pkey); - ret = EVP_DigestSignUpdate(mdctx, [data bytes], [data length]); + EVP_DigestSignInit(mdctx, NULL, EVP_sha256(), NULL, pkey); + EVP_DigestSignUpdate(mdctx, [data bytes], [data length]); size_t slen; - ret = EVP_DigestSignFinal(mdctx, NULL, &slen); + EVP_DigestSignFinal(mdctx, NULL, &slen); unsigned char* signature = malloc(slen); int result = EVP_DigestSignFinal(mdctx, signature, &slen); diff --git a/Limelight/HttpManager.m b/Limelight/HttpManager.m index 0a47d98..a2768bd 100644 --- a/Limelight/HttpManager.m +++ b/Limelight/HttpManager.m @@ -184,9 +184,8 @@ static const NSString* PORT = @"47984"; } - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { - SecIdentityRef identity = [self getClientCertificate]; // Go get a SecIdentityRef - CFArrayRef certs = [self getCertificate:identity]; // Get an array of certificates - NSArray *certArray = (__bridge NSArray *)certs; + SecIdentityRef identity = [self getClientCertificate]; + NSArray *certArray = [self getCertificate:identity]; NSURLCredential *newCredential = [NSURLCredential credentialWithIdentity:identity certificates:certArray persistence:NSURLCredentialPersistencePermanent]; @@ -194,22 +193,12 @@ static const NSString* PORT = @"47984"; } // Returns an array containing the certificate -- (CFArrayRef)getCertificate:(SecIdentityRef) identity { +- (NSArray*)getCertificate:(SecIdentityRef) identity { SecCertificateRef certificate = nil; SecIdentityCopyCertificate(identity, &certificate); - SecCertificateRef certs[1] = { certificate }; - CFArrayRef certArray = CFArrayCreate(NULL, (const void **) certs, 1, NULL); - - SecPolicyRef policyRef = SecPolicyCreateBasicX509(); - SecTrustRef trustRef; - - OSStatus status = SecTrustCreateWithCertificates(certArray, policyRef, &trustRef); - if (status != noErr) { - NSLog(@"Error Creating certificate"); - } - return certArray; + return [[NSArray alloc] initWithObjects:(__bridge id)certificate, nil]; } // Returns the identity diff --git a/Limelight/mkcert.c b/Limelight/mkcert.c index 6a2828c..50478dc 100644 --- a/Limelight/mkcert.c +++ b/Limelight/mkcert.c @@ -83,7 +83,7 @@ int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int years) { RSA *rsa; X509_NAME *name = NULL; - if ((pkeyp == NULL) || (*pkeyp == NULL)) { + if (*pkeyp == NULL) { if ((pk=EVP_PKEY_new()) == NULL) { abort(); return(0); @@ -92,7 +92,7 @@ int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int years) { pk = *pkeyp; } - if ((x509p == NULL) || (*x509p == NULL)) { + if (*x509p == NULL) { if ((x = X509_new()) == NULL) { goto err; }