Without seeing your code it is hard to say, but the probable cause is lack of nul termination on the buffers. strcat and similar functions rely on a nul or 0 byte to indicate the end of the string(s) being worked on.
To terminate a buffer you need to know where the buffer should end and add a null there so for example if I had copied 10 characters into buffer2 at I could terminate it by adding:
buffer2[10] = 0;
or
buffer2[10] = ‘\0’;
Another approach to take would be to fill the destination buffer with 0s before copying in the data so that the remainder of the buffer will always be nuls e.g.
memset(buffer2, 0, 64);
using strcat(buffer, “\0”) will not work for 2 reasons as strcat first scans the string to find the end of it which is marked by a null so you don’t know where it will end up secondly strcat(buffer, “\0”) adds a 0 length string to the end of a nul terminated string which means it does nothing!