Re: [opendemo-devel] Perfomance.
Status: Beta
Brought to you by:
girlich
From: Dr. U. G. <Uwe...@ph...> - 2002-01-08 18:44:45
|
Hello! > I come to the conclusion, that I first have to look at and understand all the > typical uses of all the fb* functions. I found a possible buffer overrun in the code: libs/od_xml_read.c/xmlParseCharacters() reads characters up to the first processing character (<,&) and discards any whitespaces up to the first real character. The main point is firstChar = -1; for (len = 0; ; len++) { c = fbReadChar(doc.fb, len); if (c == '<' || c == '&') break; ... if (!IS_BLANK(c) && firstChar == -1) firstChar = len; } So we have now len bytes checked and at the position firstChar (firstChar <= len) ends the whitespaces. If we had only 'len' whitespaces, these 'len' bytes will be ignored: if (firstChar == -1) { if (doc.sax && doc.sax->ignorableWhitespace) doc.sax->ignorableWhitespace(doc.userData, mbGetBuffer(doc.fb->mb) + doc.fb->offset, len); } else { But if we had also real data, we do something strange: if (doc.sax && doc.sax->characters) doc.sax->characters(doc.userData, mbGetBuffer(doc.fb->mb) + doc.fb->offset + firstChar, len); } This would mean, we have len characters after the firstChar position. I think, this must be: else { /* ignorable whitespace comes only between 2 tags, so we have no doc.sax->ignorableWhitespace() call here. */ /* after the white-spaces come only len-firstChar characters */ if (doc.sax && doc.sax->characters) doc.sax->characters(doc.userData, mbGetBuffer(doc.fb->mb) + doc.fb->offset + firstChar, len - firstChar); } This problem never arose, because the ODQ3A files contain no simple characters but only XML tags and everything is in attributes. I'll read the code a bit further, maybe I find something more. I intend to implement some ring-buffer code tomorrow and 'll fix this one too. Bye, Uwe |