This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Missing string termination in elf-setup-vdso.h?
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- Cc: libc-alpha at sourceware dot org, Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>
- Date: Tue, 20 Aug 2013 01:09:45 +0200
- Subject: Re: [PATCH] Missing string termination in elf-setup-vdso.h?
- References: <871u5phabz dot fsf at br87z6lw dot de dot ibm dot com>
On Mon, Aug 19, 2013 at 07:14:24PM +0200, Andreas Arnez wrote:
> While trying to understand what information is stored for VDSOs in the
> link map, I stumbled upon what looks like a missing string termination
> bug. It seems that this code is usually not reached; thus I'm not sure
> which systems are affected by this (potential) bug.
>
Looks OK for me with possible improvement. A line after diff is
l->l_libname->name = l->l_name = memcpy (copy, dsoname, len);
If it was not elf I would say just use strdup.
But xstrdup is found on several places of elf. Is xstrdup safe here?
>
> 2013-08-19 Andreas Arnez <arnez@linux.vnet.ibm.com>
>
> * elf/setup-vdso.h (setup_vdso): Fix missing string termination.
>
>
> diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
> index a98dfec..056d885 100644
> --- a/elf/setup-vdso.h
> +++ b/elf/setup-vdso.h
> @@ -89,7 +89,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
> addresses in the vsyscall DSO pages in writev() calls. */
> const char *dsoname = ((char *) D_PTR (l, l_info[DT_STRTAB])
> + l->l_info[DT_SONAME]->d_un.d_val);
> - size_t len = strlen (dsoname);
> + size_t len = strlen (dsoname) + 1;
> char *copy = malloc (len);
> if (copy == NULL)
> _dl_fatal_printf ("out of memory\n");