grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grub_strdup() error; or: grub_malloc() zeroes memory?


From: Colin D Bennett
Subject: Re: grub_strdup() error; or: grub_malloc() zeroes memory?
Date: Sat, 28 Jun 2008 08:35:26 -0700

On Sat, 28 Jun 2008 18:25:01 +0300
Vesa Jääskeläinen <address@hidden> wrote:

> Colin D Bennett wrote:
> > It looks like grub_strdup() does not terminate the returned string
> > with a 0 byte.  The only way I could see it working is if
> > grub_malloc() filled the returned memory with zeroes.  Does it?
> > 
> > From kern/misc.c: (circa line 476)
> > 
> >    char *
> >    grub_strdup (const char *s)
> >    {
> >      grub_size_t len;
> >      char *p;
> >      
> >      len = grub_strlen (s) + 1;
> >      p = (char *) grub_malloc (len);
> >      if (! p)
> >        return 0;
> > 
> >      return grub_memcpy (p, s, len);
> >    }
> 
> Zero is copied from source string... notice strlen() + 1.

Doh!
/me smacks his forehead.
Thanks for pointing that out.

Cheers,
Colin

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]