Skip to content

Commit ab9999c

Browse files
committed
Avoid directly accessing internals of ASN1_BIT_STRING
1 parent 7754442 commit ab9999c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

libgamestream/client.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,17 +541,17 @@ int gs_pair(PSERVER_DATA server, char* pin) {
541541
const ASN1_BIT_STRING *asnSignature;
542542
X509_get0_signature(&asnSignature, NULL, cert);
543543

544-
challenge_response = malloc(16 + asnSignature->length + sizeof(client_secret_data));
544+
challenge_response = malloc(16 + ASN1_STRING_length(asnSignature) + sizeof(client_secret_data));
545545
char challenge_response_hash[32];
546546
char challenge_response_hash_enc[sizeof(challenge_response_hash)];
547547
char challenge_response_hex[SIZEOF_AS_HEX_STR(challenge_response_hash_enc)];
548548
memcpy(challenge_response, challenge_response_data + hash_length, 16);
549-
memcpy(challenge_response + 16, asnSignature->data, asnSignature->length);
550-
memcpy(challenge_response + 16 + asnSignature->length, client_secret_data, sizeof(client_secret_data));
549+
memcpy(challenge_response + 16, ASN1_STRING_get0_data(asnSignature), ASN1_STRING_length(asnSignature));
550+
memcpy(challenge_response + 16 + ASN1_STRING_length(asnSignature), client_secret_data, sizeof(client_secret_data));
551551
if (server->serverMajorVersion >= 7)
552-
SHA256(challenge_response, 16 + asnSignature->length + sizeof(client_secret_data), challenge_response_hash);
552+
SHA256(challenge_response, 16 + ASN1_STRING_length(asnSignature) + sizeof(client_secret_data), challenge_response_hash);
553553
else
554-
SHA1(challenge_response, 16 + asnSignature->length + sizeof(client_secret_data), challenge_response_hash);
554+
SHA1(challenge_response, 16 + ASN1_STRING_length(asnSignature) + sizeof(client_secret_data), challenge_response_hash);
555555

556556
encrypt(challenge_response_hash, sizeof(challenge_response_hash), aes_key, challenge_response_hash_enc);
557557
bytes_to_hex(challenge_response_hash_enc, challenge_response_hex, sizeof(challenge_response_hash_enc));

0 commit comments

Comments
 (0)