This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/9728] New: Typo in sysdeps/generic/dl-osinfo.h: memcmp() should be memcpy()


Hello glibc developers,

looking at the last patch for sysdeps/generic/dl-osinfo.h (git commit
b5e9d5...) I found something strange -- in my opinion a bug.

> diff --git a/sysdeps/generic/dl-osinfo.h b/sysdeps/generic/dl-osinfo.h
> index 60b84a9..02ec28d 100644
> --- a/sysdeps/generic/dl-osinfo.h
> +++ b/sysdeps/generic/dl-osinfo.h
> @@ -1,12 +1,29 @@
>  #include <stdint.h>
>  
>  static inline uintptr_t __attribute__ ((always_inline))
> -_dl_setup_stack_chk_guard (void)
> +_dl_setup_stack_chk_guard (void *dl_random)
>  {
> -  uintptr_t ret = 0;
> -  unsigned char *p = (unsigned char *) &ret;
> -  p[sizeof (ret) - 1] = 255;
> -  p[sizeof (ret) - 2] = '\n';
> -  p[0] = 0;
> +  uintptr_t ret;
> +  if (dl_random == NULL)
> +    {
> +      ret = 0;
> +      unsigned char *p = (unsigned char *) &ret;
> +      p[sizeof (ret) - 1] = 255;
> +      p[sizeof (ret) - 2] = '\n';
> +      p[0] = 0;
> +    }
> +  else
> +    memcmp (&ret, dl_random, sizeof (ret));

I guess this should have been memcpy() here.

> +  return ret;
> +}
> +
> +static inline uintptr_t __attribute__ ((always_inline))
> +_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard)
> +{
> +  uintptr_t ret;
> +  if (dl_random == NULL)
> +    ret = stack_chk_guard;
> +  else
> +    memcmp (&ret, (char *) dl_random + sizeof (ret), sizeof (ret));

Likewise.

>    return ret;
>  }


Best regards,
Mathias Krause

-- 
           Summary: Typo in sysdeps/generic/dl-osinfo.h: memcmp() should be
                    memcpy()
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: mkrause at informatik dot tu-cottbus dot de
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=9728

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]