sillsdev / libpalaso

Palaso Library: A set of .Net libraries useful for developers of Language Software.
MIT License
44 stars 50 forks source link

LogBox doesn't check to see whether text to append will fit #843

Open tombogle opened 5 years ago

tombogle commented 5 years ago

The RichTextBox control uses the default size limit of MaxValue as its MaxLength. We need to check to see whether the text to append will fit, as described here.

tombogle commented 5 years ago

In practice (and certainly on a 32-bit machine), strings can't really get that big (see: https://stackoverflow.com/questions/140468/what-is-the-maximum-possible-length-of-a-net-string). Long before we get close to MaxLength, we're going to either get an OutOfMemoryException or and AccessViolationException. To make things even crazier, LogBox.Text and LogBox.Rtf currently return values that includes the label Box:, followed by all the non-verbose text, followed by the label Verbose:, followed by all the verbose text (with includes the non-verbose). In the case of Rtf, this is already considerably larger than the plain text. So accessing one of these properties can easily attempt to create a string that could be more than double MaxLength. I don;t know if these implementations are particularly useful or if any existing production code accesses them.

tombogle commented 5 years ago

WIP: https://github.com/sillsdev/libpalaso/pull/845

ermshiperete commented 4 years ago

@tombogle is this still an issue, or did #845 fix this?