Posted by Nico Golde in
random blurb
Friday, January 5. 2007
grep -n -A 10 "FIXME avoid" xmlparse.c
/* FIXME avoid integer overflow */
buffer = buffer == 0 ? malloc(len * 2) : realloc(buffer, len * 2);
if (!buffer) {
errorCode = XML_ERROR_NO_MEMORY;
eventPtr = eventEndPtr = 0;
return 0;
}
bufferLim = buffer + len * 2;
}
memcpy(buffer, end, nLeftOver);
bufferPtr = buffer;
/*** A FEW LINES LATER, SAME CODE ***/
/* FIXME avoid integer overflow */
int neededSize = len + (bufferEnd - bufferPtr);
if (neededSize <= bufferLim - buffer) {
memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
bufferEnd = buffer + (bufferEnd - bufferPtr);
bufferPtr = buffer;
}
else {
char *newBuf;
int bufferSize = bufferLim - bufferPtr;
if (bufferSize == 0)
Obviously the guy who wrote this has humor.