Back to success stories

Sample of Defect

Project Name CID Checker Category Developer Description
Zarafa 42988 COPY_PASTE_ERROR Incorrect expression Coverity found a case where a copy/paste action went wrong. It could cause e-mails stored with incorrect names. That usually upsets customers.
File: /inetmapi/MAPIToVMIME.cpp
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
                else
                        vmHeader->From()->setValue(vmime::mailbox(getVmimeTextFromWide(strResName), m_converter.convert_to<string>(strResEmail)));

                // spooler checked if this is allowed
                if (strResEmail != strEmail) {
                        // Set store owner as sender
                        if (strName.empty() || strName == strEmail) 
                                vmHeader->Sender()->setValue(vmime::mailbox(m_converter.convert_to<string>(strEmail)));
                        else
                                vmHeader->Sender()->setValue(vmime::mailbox(getVmimeTextFromWide(strName), m_converter.convert_to<string>(strEmail)));
                }
        } else {
                // Set store owner as from, sender does not need to be set
                if (strName.empty() || strName == strEmail) 
                        vmHeader->From()->setValue(vmime::mailbox(m_converter.convert_to<string>(strEmail)));
                else
                        vmHeader->From()->setValue(vmime::mailbox(getVmimeTextFromWide(strName), m_converter.convert_to<string>(strEmail)));
        }

        // read receipt request
        if ((HrGetOneProp(lpMessage, PR_READ_RECEIPT_REQUESTED, &lpReadReceipt) == hrSuccess) && (lpReadReceipt->Value.b == TRUE)) {
                vmime::mailboxList mbl;
                if (!strResEmail.empty() && strResEmail != strEmail) {
                        // use user added from address
 <<< CID 42988: Incorrect expression COPY_PASTE_ERROR
 <<< "strName" in "strName" looks like a copy-paste error.
 < Should it say "strResName" instead?
2142
2143
2144
2145
2146
                        if (strResName.empty() || strName == strResEmail)
                                mbl.appendMailbox(vmime::create<vmime::mailbox>(m_converter.convert_to<string>(strResEmail)));
                        else
                                mbl.appendMailbox(vmime::create<vmime::mailbox>(getVmimeTextFromWide(strResName), m_converter.convert_to<string>(strResEmail)));
                } else {
 << "strName" looks like the original copy.
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
                        if (strName.empty() || strName == strEmail)
                                mbl.appendMailbox(vmime::create<vmime::mailbox>(m_converter.convert_to<string>(strEmail)));
                        else
                                mbl.appendMailbox(vmime::create<vmime::mailbox>(getVmimeTextFromWide(strName), m_converter.convert_to<string>(strEmail)));
                }
                vmHeader->DispositionNotificationTo()->setValue(mbl);
        }

exit:
        if (lpPropTags)
                MAPIFreeBuffer(lpPropTags);

        if (lpProps)
                MAPIFreeBuffer(lpProps);

        if (lpReadReceipt)
                MAPIFreeBuffer(lpReadReceipt);

        return hr;
}

/**
 * Set Reply-To header.
 *
 * @note In RFC-822 and MAPI, you can set multiple Reply-To
 * values. However, in vmime this is currently not possible, so we
 * only convert the first.
Events:
remediation MAPIToVMIME.cpp:2142
original MAPIToVMIME.cpp:2147
copy_paste_error MAPIToVMIME.cpp:2142