mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-18 11:30:04 +00:00
Merge branch 'release/3.5.1'
This commit is contained in:
commit
a561e5c3dd
@ -48,6 +48,7 @@ static NSString* const kBITAuthenticatorAuthTokenKey = @"BITAuthenticatorAuthTok
|
|||||||
static NSString* const kBITAuthenticatorAuthTokenTypeKey = @"BITAuthenticatorAuthTokenTypeKey";
|
static NSString* const kBITAuthenticatorAuthTokenTypeKey = @"BITAuthenticatorAuthTokenTypeKey";
|
||||||
|
|
||||||
typedef unsigned int bit_uint32;
|
typedef unsigned int bit_uint32;
|
||||||
|
static unsigned char kBITPNGHeader[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
|
static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
|
||||||
|
|
||||||
@implementation BITAuthenticator {
|
@implementation BITAuthenticator {
|
||||||
@ -700,43 +701,55 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((fs.st_size < 20) || (memcmp(source, kBITPNGHeader, 8))) {
|
||||||
|
// Not a PNG
|
||||||
|
free(source);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = source + 8;
|
||||||
|
|
||||||
|
NSString *result = nil;
|
||||||
bit_uint32 length;
|
bit_uint32 length;
|
||||||
unsigned char *name;
|
unsigned char *name;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
NSString *result = nil;
|
int chunk_index = 0;
|
||||||
|
long long bytes_left = fs.st_size - 8;
|
||||||
buffer = source + 8;
|
|
||||||
int index = 0;
|
|
||||||
do {
|
do {
|
||||||
memcpy(&length, buffer, 4);
|
memcpy(&length, buffer, 4);
|
||||||
length = ntohl(length);
|
length = ntohl(length);
|
||||||
name = (unsigned char *)malloc(4);
|
|
||||||
|
|
||||||
buffer += 4;
|
buffer += 4;
|
||||||
|
name = (unsigned char *)malloc(4);
|
||||||
memcpy(name, buffer, 4);
|
memcpy(name, buffer, 4);
|
||||||
|
|
||||||
buffer += 4;
|
buffer += 4;
|
||||||
data = (unsigned char *)malloc(length + 1);
|
data = (unsigned char *)malloc(length + 1);
|
||||||
memcpy(data, buffer, length);
|
|
||||||
buffer += length;
|
|
||||||
buffer += 4;
|
|
||||||
|
|
||||||
if (!strcmp((const char *)name, "tEXt")) {
|
if (bytes_left >= length) {
|
||||||
data[length] = 0;
|
memcpy(data, buffer, length);
|
||||||
NSString *key = [NSString stringWithCString:(char *)data encoding:NSUTF8StringEncoding];
|
|
||||||
|
|
||||||
if ([key isEqualToString:@"Data"]) {
|
buffer += length;
|
||||||
result = [NSString stringWithCString:(char *)(data + key.length + 1) encoding:NSUTF8StringEncoding];
|
buffer += 4;
|
||||||
|
if (!strcmp((const char *)name, "tEXt")) {
|
||||||
|
data[length] = 0;
|
||||||
|
NSString *key = [NSString stringWithCString:(char *)data encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
|
if ([key isEqualToString:@"Data"]) {
|
||||||
|
result = [NSString stringWithCString:(char *)(data + key.length + 1) encoding:NSUTF8StringEncoding];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!memcmp(name, kBITPNGEndChunk, 4)){
|
if (!memcmp(name, kBITPNGEndChunk, 4)){
|
||||||
index = 128;
|
chunk_index = 128;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
free(name);
|
free(name);
|
||||||
} while (index++ < 128);
|
|
||||||
|
bytes_left -= (length + 3 * 4);
|
||||||
|
} while ((chunk_index++ < 128) && (bytes_left > 8));
|
||||||
|
|
||||||
free(source);
|
free(source);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user