Wednesday, May 2, 2012

Rudiments Update - 0.36.1 (Urgent)

There's bug in Rudiments, version 0.36 in the charstring::copy method that can cause various problems including segmentation faults. Version 0.36.1 has just been released to fix the problem. Please update.

For anyone who just wants to fix version 0.36, the fix is simple... Just edit src/charstring.cpp and look for the copy() method around like 842. It currently calls rawbuffer::copy but should be modified to have the following implementation:

char *charstring::copy(char *dest, const char *source, size_t size) {
 return strncpy(dest,source,size);

I changed the code in 0.36 to fix a problem on windows but the new code doesn't work properly for what should have been obvious reasons when I made the change. strncpy() will stop when it hits a null-terminator but rawbuffer::copy will copy "size" bytes no matter what, even if that's past the end of the string and off into the weeds.