Examples of errors detected by the V549 diagnostic
V549. The 'first' argument of 'Foo' function is equal to the 'second' argument.
Open Metronome
V549 The first argument of '_swab' function matches it's the second argument. metronome metblinker.cpp 117
CMetBlinker::CMetBlinker(....)
{
....
_swab((char*)&*m_aaActualBitmapBits[i].begin(),
(char*)&*m_aaActualBitmapBits[i].begin(),
NumberOfPixels/8);
....
}
ReactOS
V549 The first argument of 'strcmp' function matches it's the second argument. stlport locale.cpp 211
static void _Stl_loc_combine_names(_Locale_impl* L,
const char* name1, const char* name2,
locale::category c)
{
if ((c & locale::all) == 0 ||
strcmp(name1, name1) == 0)
....
}
This is what should have been written here: strcmp(name1, name2)
Chromium
V549 The first argument of 'memcmp' function is equal to the second argument. entry_unittest.cc 393
void DiskCacheEntryTest::ExternalSyncIOBackground(....) {
....
scoped_refptr<net::IOBuffer>
buffer1(new net::IOBuffer(kSize1));
scoped_refptr<net::IOBuffer>
buffer2(new net::IOBuffer(kSize2));
....
EXPECT_EQ(0, memcmp(buffer2->data(), buffer2->data(), 10000));
....
}
CryEngine 3 SDK
V549 The first argument of 'stricmp' function is equal to the second argument. ishader.h 2089
inline bool operator != (const SEfResTexture &m) const
{
if (stricmp(m_Name.c_str(), m_Name.c_str()) != 0 ||
m_TexFlags != m.m_TexFlags ||
m_bUTile != m.m_bUTile ||
m_bVTile != m.m_bVTile ||
m_Filter != m.m_Filter ||
m_Ext != m.m_Ext ||
m_Sampler != m.m_Sampler)
return true;
return false;
}
Micro-Manager
V549 The first argument of 'strcmp' function is equal to the second argument. XLedDev.cpp 119
int XLedDev::Initialize()
{
....
if (strcmp(
XLed::Instance()->GetXLedStr(XLed::XL_WLedDevName +
m_nLedDevNumber).c_str(),
XLed::Instance()->GetXLedStr(XLed::XL_WLedDevName +
m_nLedDevNumber).c_str()
) != 0)
....
}
Miranda NG
V549 The first argument of 'memcpy' function is equal to the second argument. NimContact http.cpp 46
int InternetDownloadFile (char *szUrl)
{
....
CopyMemory(nlhr.headers,nlhr.headers,
sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
....
}
Miranda NG
V549 The first argument of 'wcscpy' function is equal to the second argument. Spamotron utils.cpp 218
TCHAR* get_response(TCHAR* dst, unsigned int dstlen, int num)
{
....
TCHAR *tmp, *src = NULL;
....
src = (TCHAR*)malloc(MAX_BUFFER_LENGTH * sizeof(TCHAR));
....
_tcscpy(src, src);
....
}
The GTK+ Project
V549 The first argument of 'strcmp' function is equal to the second argument. gtkrc.c 1400
GtkStyle *
gtk_rc_get_style_by_paths (....)
{
....
pos = gtk_widget_path_append_type (path, component_type);
if (component_name != NULL &&
strcmp (component_name, component_name) != 0) // <=
gtk_widget_path_iter_set_name (path, pos, component_name);
....
}
GDB
V549 The first argument of 'memcmp' function is equal to the second argument. psymtab.c 1580
static int
psymbol_compare (const void *addr1, const void *addr2,
int length)
{
struct partial_symbol *sym1 = (struct partial_symbol *) addr1;
struct partial_symbol *sym2 = (struct partial_symbol *) addr2;
return (memcmp (&sym1->ginfo.value, &sym1->ginfo.value,
sizeof (sym1->ginfo.value)) == 0
&& sym1->ginfo.language == sym2->ginfo.language
&& PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2)
&& PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2)
&& sym1->ginfo.name == sym2->ginfo.name);
}
Linux Kernel
V549 The first argument of 'memcpy' function is equal to the second argument. wilc_wfi_cfgoperations.c 1345
static int del_pmksa(struct wiphy *wiphy,
struct net_device *netdev,
struct cfg80211_pmksa *pmksa)
{
....
for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
memcpy(priv->pmkid_list.pmkidlist[i].bssid,
priv->pmkid_list.pmkidlist[i + 1].bssid,
ETH_ALEN);
memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
priv->pmkid_list.pmkidlist[i].pmkid,
PMKID_LEN);
}
....
}
CryEngine V
V549 The first argument of 'memcpy' function is equal to the second argument. ObjectsTree_Serialize.cpp 1135
void COctreeNode::LoadSingleObject(....)
{
....
float* pAuxDataDst = pObj->GetAuxSerializationDataPtr(....);
const float* pAuxDataSrc = StepData<float>(....);
memcpy(pAuxDataDst, pAuxDataDst, min(....) * sizeof(float));
....
}
Skia Graphics Engine
V549 CWE-688 The first argument of 'memcmp' function is equal to the second argument. skpdfcanon.h 67
inline bool operator==(const SkPDFCanon::BitmapGlyphKey& u,
const SkPDFCanon::BitmapGlyphKey& v) {
return memcmp(&u, &u, sizeof(SkPDFCanon::BitmapGlyphKey)) == 0;
}
A typo due to which a u object is compared with itself.
Android
V549 CWE-688 The first argument of 'strcpy' function is equal to the second argument. genPCLm.cpp 1181
void PCLmGenerator::writeJobTicket() {
// Write JobTicket
char inputBin[256];
char outputBin[256];
if (!m_pPCLmSSettings) {
return;
}
getInputBinString(m_pPCLmSSettings->userInputBin, &inputBin[0]);
getOutputBin(m_pPCLmSSettings->userOutputBin, &outputBin[0]);
strcpy(inputBin, inputBin);
strcpy(outputBin, outputBin);
....
}
Similar errors can be found in some other places:
- V549 CWE-688 The first argument of 'strcpy' function is equal to the second argument. genPCLm.cpp 1182
Amazon Lumberyard
V549 CWE-688 The first argument of 'memcmp' function is equal to the second argument. meshutils.h 894
struct VertexLess
{
....
bool operator()(int a, int b) const
{
....
if (m.m_links[a].links.size() != m.m_links[b].links.size())
{
res = (m.m_links[a].links.size() <
m.m_links[b].links.size()) ? -1 : +1;
}
else
{
res = memcmp(&m.m_links[a].links[0], &m.m_links[a].links[0],
sizeof(m.m_links[a].links[0]) * m.m_links[a].links.size());
}
....
}
....
};
PMDK
V549 [CWE-688] The first argument of 'memmove' function is equal to the second argument. memmove_common.c 71
void
do_memmove(char *dst, char *src, const char *file_name,
size_t dest_off, size_t src_off, size_t bytes,
memmove_fn fn, unsigned flags, persist_fn persist)
{
....
/* do the same using regular memmove and verify that buffers match */
memmove(dstshadow + dest_off, dstshadow + dest_off, bytes / 2);
verify_contents(file_name, 0, dstshadow, dst, bytes);
verify_contents(file_name, 1, srcshadow, src, bytes);
....
}
DPDK
V549 The first argument of 'memcmp' function is equal to the second argument. test_link_bonding.c 795
static int
test_set_primary_member(void)
{
....
TEST_ASSERT_SUCCESS(memcmp(expected_mac_addr, &read_mac_addr,
sizeof(read_mac_addr)),
"bonding port mac address not set to that of primary port\n");
....
TEST_ASSERT_SUCCESS(memcmp(&read_mac_addr, &read_mac_addr, // <=
sizeof(read_mac_addr)),
"bonding port mac address not set to that of primary port\n");
....
}
DPDK
V549 The first argument of 'memcmp' function is equal to the second argument. ptpclient.c 371
static void
parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx)
{
....
if (ptp_data->ptpset == 0) {
rte_memcpy(&ptp_data->master_clock_id,
&ptp_hdr->source_port_id.clock_id,
sizeof(struct clock_id));
ptp_data->ptpset = 1;
}
if (memcmp(&ptp_hdr->source_port_id.clock_id,
&ptp_hdr->source_port_id.clock_id,
sizeof(struct clock_id)) == 0) {
....
}