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

Colin JN Breame colin at breame.net
Tue Mar 14 10:50:01 EST 2006


On Tuesday 14 March 2006 15:37, Gonzalo Paniagua Javier wrote:
> 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

From what I can tell, it looks sound.

 -- Colin


More information about the Mono-list mailing list