Download Latest Version trees geo+mesh.zip (8.0 MB)
Email in envelope

Get an email when there's a new version of Auto-TS

Home / AOKTS update
Name Modified Size InfoDownloads / Week
Parent folder
backup folder 2015-07-12
readme.txt 2015-06-28 1.8 kB
aokts-1.0.1 corrected.zip 2015-06-28 1.6 MB
Totals: 3 Items   1.6 MB 0
README

INTRODUTION

Trigger Paste Bug at AOKTS

There was a trigger paste bug in versions of AOKTS 1.0, 1.0.1 and 1.0.2. This bug crashed AOKTS when debuging in a debug configuration.

I see nobody to correct this bug, so I had the effort to analyze the code and find it. In release version the bug did this: if you copy trigger and then paste it you see some strange characters on the end of the pasted item (trigger). The reason is this that the function which copies the Trigger name:

void MemBuffer::reads(char *dest, const size_t lensize)
{
	size_t len = 0;

	checkFits(lensize);

	memcpy(&len, pos, lensize);
	pos += lensize;

	checkFits(len);
	if (len)
		memcpy(dest, pos, len);
	else
		*dest = '\0';

	pos += len;
}

Does not return len. The length of the destination string.

The paste action if made in Trigger::Trigger(Buffer& buffer):
see this line:
buffer.reads(name, sizeof(long));
The complete buffer of length 128 characters is copied. The empty buffer contains characters 0x03 Ì. It copies e.g. 10 characters to string name, but at the result, the length is lost and so it copies more characters not just the trigger name.

SOLUTION:

My solution is to return len and add null character to name.

size_t name_len = buffer.reads(name, sizeof(long));
if (name_len < MAX_TRIGNAME)
		name[name_len]='\0';


This includes to change return type of the function
void MemBuffer::reads
to
size_t MemBuffer::reads
and all derived function have to change the return type too.

CONCLUSION:

I am very happy I could repair this bug. It should not affect AOKTS behavious except the paste action.
Because I have no idea, what changes was done on version 1.0.2 I could not repair that versions.

Rumburak24 (aok.heavengames.com)
Source: readme.txt, updated 2015-06-28