Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#34 ATL8: eVC4SP4 bug in SecureHelper::strcpyW_x()

open
None
5
2007-11-28
2007-07-13
No

ATL8: It seems eVC4SP4 ARMV4 compiler is generating wrong code for SecureHelper::strcpyW_x() in _DEBUG mode. A way to fix it is to explicitely put the ATLVERIFY() line inside a block :

if(cchDest > (size_t)lstrlenW(lpstrSrc)) {
ATLVERIFY(lstrcpyW(lpstrDest, lpstrSrc) != NULL);
}

Here is the detailed explanation :

706: #if _SECURE_ATL
707: ATL::Checked::wcscpy_s(lpstrDest, cchDest, lpstrSrc);
708: #else
709: if(cchDest > (size_t)lstrlenW(lpstrSrc))
1C032284 ldr r0, [sp, #0x18]
1C032288 bl |wcslen (1c0c7340)|
1C03228C str r0, [sp]
1C032290 ldr r1, [sp, #0x14]
1C032294 ldr r0, [sp]
1C032298 cmp r1, r0
1C03229C bls |$M126228+44h (1c0322c8)|
710: ATLVERIFY(lstrcpyW(lpstrDest, lpstrSrc) != NULL);
1C0322A0 ldr r1, [sp, #0x18]
1C0322A4 ldr r0, [sp, #0x10]
1C0322A8 bl |wcscpy (1c0c758c)|
1C0322AC str r0, [sp, #4]
1C0322B0 ldr r1, [sp, #4]
1C0322B4 cmp r1, #0
1C0322B8 bne |$M126228+40h (1c0322c4)|
1C0322BC DCD 0xE6000010
711: else
1C0322C0 b |$M126228+44h (1c0322c8)|
712: ATLASSERT(FALSE);
1C0322C4 DCD 0xE6000010
713: #endif
714: }
1C0322C8 add sp, sp, #8
1C0322CC ldmia sp, {sp, pc}

as you can see, the whole statement logic is upside-down. The DebugBreak() statement at 1C0322C4 is not reached when wcslen returns more than the cchDest value, and is reached when wcscpy returns a non-zero result.
I don't know whether the error is coming from the preprocessor or the ARMV4 compiler itself.

Discussion

    • assigned_to: nobody --> nenadstefanovic