mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
CryptoPkg: TlsLib: Fix uninitialized variable warnings
In TlsSetCipherList(), the OpensslCipher variable is initialized inside an inner loop but accessed outside of that loop, which can lead to uninitialized variable warnings. Fix this issue by moving all accesses to OpensslCipher into the inner loop where it is initialized. Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
This commit is contained in:
parent
42b690316c
commit
798a16c520
1 changed files with 31 additions and 31 deletions
|
|
@ -227,9 +227,38 @@ TlsSetCipherList (
|
|||
//
|
||||
for (StackIdx = 0; StackIdx < sk_SSL_CIPHER_num (OpensslCipherStack); StackIdx++) {
|
||||
OpensslCipher = sk_SSL_CIPHER_value (OpensslCipherStack, StackIdx);
|
||||
if (CipherId[Index] == SSL_CIPHER_get_protocol_id (OpensslCipher)) {
|
||||
break;
|
||||
if (CipherId[Index] != SSL_CIPHER_get_protocol_id (OpensslCipher)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Accumulate cipher name string length into CipherStringSize. If this
|
||||
// is not the first successful mapping, account for a colon (":") prefix
|
||||
// too.
|
||||
//
|
||||
if (MappedCipherCount > 0) {
|
||||
Status = SafeUintnAdd (CipherStringSize, 1, &CipherStringSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto FreeMappedCipher;
|
||||
}
|
||||
}
|
||||
|
||||
Status = SafeUintnAdd (
|
||||
CipherStringSize,
|
||||
AsciiStrLen (SSL_CIPHER_get_name (OpensslCipher)),
|
||||
&CipherStringSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto FreeMappedCipher;
|
||||
}
|
||||
|
||||
//
|
||||
// Record the mapping.
|
||||
//
|
||||
MappedCipher[MappedCipherCount++] = OpensslCipher;
|
||||
break;
|
||||
}
|
||||
|
||||
if (StackIdx == sk_SSL_CIPHER_num (OpensslCipherStack)) {
|
||||
|
|
@ -245,36 +274,7 @@ TlsSetCipherList (
|
|||
// preference list of ciphers, thus we can filter it as long as we
|
||||
// don't change the relative order of elements on it.
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Accumulate cipher name string length into CipherStringSize. If this
|
||||
// is not the first successful mapping, account for a colon (":") prefix
|
||||
// too.
|
||||
//
|
||||
if (MappedCipherCount > 0) {
|
||||
Status = SafeUintnAdd (CipherStringSize, 1, &CipherStringSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto FreeMappedCipher;
|
||||
}
|
||||
}
|
||||
|
||||
Status = SafeUintnAdd (
|
||||
CipherStringSize,
|
||||
AsciiStrLen (SSL_CIPHER_get_name (OpensslCipher)),
|
||||
&CipherStringSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto FreeMappedCipher;
|
||||
}
|
||||
|
||||
//
|
||||
// Record the mapping.
|
||||
//
|
||||
MappedCipher[MappedCipherCount++] = OpensslCipher;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue