Skip to content

Commit 72cfce2

Browse files
author
Danny Greg
committed
Merge remote branch 'remotes/0xced/master'
2 parents 71b2e7f + 1a6c569 commit 72cfce2

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

objc/NSString+PECrypt.m

+3-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,10 @@
1616
@implementation NSString (PXCrypt)
1717

1818
- (NSData *)sha1 {
19-
const int DIGEST_LEN = 20;
20-
unsigned char *buf = malloc(DIGEST_LEN);
19+
unsigned char digest[SHA_DIGEST_LENGTH];
2120
const char *str = [self UTF8String];
22-
size_t len = strlen(str);
23-
unsigned char *p = SHA1((unsigned char *)str, len, buf);
24-
if (!p) {
25-
free(buf);
26-
return nil;
27-
}
28-
NSData *digest = [NSData dataWithBytes:buf length:DIGEST_LEN];
29-
free(buf);
30-
return digest;
21+
SHA1((unsigned char *)str, strlen(str), digest);
22+
return [NSData dataWithBytes:digest length:SHA_DIGEST_LENGTH];
3123
}
3224

3325
// Based on Dave Dribin's code, http://www.dribin.org/dave/blog/archives/2006/03/12/base64_cocoa/

objc/encoder.c

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ base32_encoder_encode_bits (int position, const uint8_t *buffer)
8484
case 7:
8585
return
8686
buffer[offset + 4] & 0x1F;
87+
88+
default:
89+
return 0;
8790
}
8891
}
8992

0 commit comments

Comments
 (0)