Crash in Registry.cpp - "Run-Time Check Failure #2 - Stack around the variable 'lpstrData' was corrupted."

Bug #872768 reported by Samphan Raruenrom
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OCS Inventory: Windows Agent
Fix Released
Low
Didier Liroulet

Bug Description

I've built the agent on Windows 7 and encounter a crash in CRegistry::GetRegistryApplicationsNT
Look at the code:-

        DWORD dwSize = 256;
     TCHAR lpstrData[256];
     DWORD dwResult;

     dwResult = VerLanguageName( dwLanguage, lpstrData, dwSize);
     if ((dwResult != 0) && (dwResult < dwSize - 1))
     {
      lpstrData[dwSize]=0;
      csLanguage = lpstrData;
     }
There's also the same code in CRegistry::GetRegistryApplications9X()

The line "lpstrData[dwSize]=0" look suspicious. So I change it to "lpstrData[dwResult]=0" and the problem is fixed.

Actually, I think the line can be removed altogether because VerLanguageName() already null-terminated the result. I've tried so and it is OK. It've attached the patch to show my idea.

Revision history for this message
Samphan Raruenrom (samphan) wrote :
Revision history for this message
Didier Liroulet (dliroulet) wrote :

Hi.

You're right.

I fix it for next release.

Thanks a lot for the report.

Cheers

Changed in ocsinventory-windows-agent:
assignee: nobody → Didier Liroulet (dliroulet)
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Didier Liroulet (dliroulet) wrote :

Fix commited, See revision 320

Cheers

Changed in ocsinventory-windows-agent:
status: Confirmed → Fix Committed
Changed in ocsinventory-windows-agent:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.