GetItemLink (MQ2Main/MQ2Utilities.cpp) broken

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

demonstar55
a snow griffon
a snow griffon
Posts: 314
Joined: Fri Nov 28, 2008 6:31 am

GetItemLink (MQ2Main/MQ2Utilities.cpp) broken

Post by demonstar55 » Wed Sep 07, 2016 1:23 am

Minor mistake in the string safety patch, but the Buffer passed in is the return Buffer

This is the current broken code.

Code: Select all

BOOL GetItemLink(PCONTENTS Item, PCHAR Buffer, BOOL Clickable)
{
	CHAR szCmd[MAX_STRING] = { 0 };
	strcpy_s(szCmd, Buffer);
	char hash[MAX_STRING] = { 0 };
	bool retVal = FALSE;
	((EQ_Item*)Item)->CreateItemTagString(hash, sizeof(hash));
	if (hash[0]) {
		if (Clickable)
			sprintf_s(szCmd, "%c0%s%s%c", 0x12, hash, GetItemFromContents(Item)->Name, 0x12);
		else
			sprintf_s(szCmd, "0%s%s", hash, GetItemFromContents(Item)->Name);
		retVal = TRUE;
	}
	DebugSpew("GetItemLink() returns '%s'", &szCmd[0]);
	return retVal;
I'm not 100% sure on the best solution in the name of safeness, but the at least with how it is now, szCmd needs to be copied back into Buffer. The Buffer should also be empty so doesn't need to be copied.

SwiftyMUSE
Developer
Developer
Posts: 1205
Joined: Tue Sep 23, 2003 10:52 pm

Re: GetItemLink (MQ2Main/MQ2Utilities.cpp) broken

Post by SwiftyMUSE » Wed Sep 07, 2016 10:17 am

Sorry, I thought EQMule got the fix for this in already. We discussed it a while ago.
PayPal: Donate to SwiftyMUSE
Bitcoin: 1LuQ6YcEAWxF3fm9yWMiro4K582je7364V
Krono: PM me

dont_know_at_all wrote:Gee, if only there was a way to correctly report a crash...

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Re: GetItemLink (MQ2Main/MQ2Utilities.cpp) broken

Post by EqMule » Fri Sep 09, 2016 3:03 pm

Fixed this today, it will be released in the next zip.
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.