Suspicious variable
Posted: Thu Aug 01, 2024 2:16 pm
The following snippets are from v3.5.2.
In File SslSocket.cpp, beginning at line 274, It appears that local variable 'ret' can be used uninitialized at line 298.
Also:
In File: C:\nburn\arch\coldfire\cpu\MCF5441X\source\Wire.cpp, is the assignment in the second 'if' statement, line 546, correct?
In File: C:\nburn\platform\NANO54415\source\sdhc_mcf.cpp, line 713. Variable 'bus_width' is declared twice, and I believe 'if (bus_width==0)' will always evaluate to true. Is that the way it's supposed to work?
In File SslSocket.cpp, beginning at line 274, It appears that local variable 'ret' can be used uninitialized at line 298.
Code: Select all
uint16_t SslSocket::InitSocket(int tcpFd, WOLFSSL_CTX *ctx, const char *commonName, uint32_t sockFlags /* = 0 */, int verifyPeer)
{
OSCriticalSectionObj crit(m_Crit);
uint16_t ret, error;
char errorBuf[80]; // Buffer to hold text version of error code
if(sockFlags != 0)
{
SetFlag(sockFlags);
}
SSL_DEBUG_IPRINTF("Getting Socket - ctx: %p - Flags: %#08lx - sockFlags: %#08lx\r\n",
ctx, GetFlags(), sockFlags);
CryptoSocket::InitSocket(tcpFd, &SslIoExpand);
SSL_DEBUG_IPRINTF("Flags: %#08lx", GetFlags());
SSL_DEBUG_IPRINTF("ctx->certificate: %p\r\n",ctx->certificate);
if (ctx->certificate)
{
const int derBufSz = 4096;
const int pemBufSz = 4096;
puint8_t gDerBuf = new(std::nothrow) uint8_t[derBufSz];
puint8_t gPemBuf = new(std::nothrow) uint8_t[pemBufSz];
int ps=wc_DerToPem(gDerBuf, ret,gPemBuf,pemBufSz,CERT_TYPE);
if(ps>0)
SSL_DEBUG_IPRINTF("%s\r\n", gPemBuf);
delete gDerBuf;
delete gPemBuf;
}
...
In File: C:\nburn\arch\coldfire\cpu\MCF5441X\source\Wire.cpp, is the assignment in the second 'if' statement, line 546, correct?
Code: Select all
int TwoWire::readRegN(uint8_t devAddr, uint32_t reg, uint8_t *buf, uint32_t blen)
{
beginTransmission(devAddr);
write((uint8_t)reg);
int rv= requestFrom(devAddr,blen,true);
if (available())
{
int nread=read(buf,blen);
if (nread=blen) return wire_success;
}
return rv;
}
Code: Select all
uint32_t bus_width = 0;
if (get_scr(drv, &sdhc_dsc[drv].SCR[0], sizeof(sdhc_dsc[0].SCR)) == SDHC_NO_ERROR)
{
uint32_t bus_width = get_dev_reg_bits(sdhc_dsc[drv].SCR, sizeof(sdhc_dsc[0].SCR) * 8, SCR_SD_BUS_WIDTH_POS, SCR_SD_BUS_WIDTH_LEN);
SDHC_LOG_DEBUG("SD_BUS_WIDTH=0x%x\n\r", (uint16_t)bus_width);
if ((bus_width & 0x4) != 0) { bus_width = 4; }
else if ((bus_width & 0x1) != 0)
{
bus_width = 1;
}
else
bus_width = 0;
sdhc_dsc[drv].dat_bus_width = bus_width;
}
if (bus_width == 0) bus_width = 4;
...