send_buffer has size numbytes. You then copy numbytes worth of data onto a place starting after the beginning of send_buffer. Looks like a buffer overflow to me! Simplest fix is to have an intermediate buffer for the header, and only allocate send_buffer once we know how big it needs to be.
I recognize that it wouldn't be C without a buffer overflow or two. That said:
send_buffer
has sizenumbytes
. You then copynumbytes
worth of data onto a place starting after the beginning ofsend_buffer
. Looks like a buffer overflow to me! Simplest fix is to have an intermediate buffer for the header, and only allocatesend_buffer
once we know how big it needs to be.