[Mono-list] Mono.Unix.Native.Syscall.readlink memory corruption

Gonzalo Paniagua Javier gonzalo at ximian.com
Tue Mar 14 10:37:39 EST 2006


On Mon, 2006-03-13 at 18:16 -0600, Jonathan Gilbert wrote:
> At 04:12 PM 13/03/2006 -0500, Gonzalo Paniagua Javier wrote:
> >On Mon, 2006-03-13 at 17:32 +0000, Colin JN Breame wrote:
> >> using System.Text;
> >> public class main_t {
> >>   public static void Main() {
> >>     for (int i=0; i<10000; i++) {
> >>       StringBuilder buf = new StringBuilder();
> >>       Mono.Unix.Native.Syscall.readlink("path/to/link/file", buf);
> >>     }
> >>   }
> >> } 
> >
> >Confirmed. I get the same error.
> 
> Don't you need to give the StringBuilder a capacity first? Is the default
> capacity documented, and documented to be large enough for the return value
> of readlink()?

Yes, you are supposed to pass a StringBuilder with the appropiate
capacity, but in any case there should not be a memory corruption.

Here's a patch that fixes the corruption problem. May I commit?

-Gonzalo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: marshal.patch
Type: text/x-patch
Size: 1052 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20060314/8bb33f43/marshal.bin


More information about the Mono-list mailing list