]> code.ossystems Code Review - openembedded-core.git/commit
glibc: fix Segmentation fault in gethostid.c
authorMingli Yu <Mingli.Yu@windriver.com>
Fri, 21 Sep 2018 03:43:10 +0000 (11:43 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 21 Sep 2018 15:15:19 +0000 (08:15 -0700)
commit92c266fd9b1c4034a13bd5b102d1817df388a7b5
tree5da77fffeb1f24b01eb5f790eda267ac6d837114
parent216f8ea907c8ac7e580e33dcbd12c0f30608bf74
glibc: fix Segmentation fault in gethostid.c

Linux gethostid: Check for NULL value from gethostbyname_r [BZ #23679]

A NULL value can happen with certain gethostbyname_r failures.

Before this patch, there is a Segmentation fault
as below:
 # /mybuild/hostid
 Segmentation fault
 # gdb /mybuild/hostid
 GNU gdb (GDB) 8.2
 Copyright (C) 2018 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
 Type "show copying" and "show warranty" for details.
 This GDB was configured as "x86_64-wrs-linux".
 Type "show configuration" for configuration details.
 For bug reporting instructions, please see:
 <http://www.gnu.org/software/gdb/bugs/>.
 Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

 For help, type "help".
 Type "apropos word" to search for commands related to "word"...
 Reading symbols from /mybuild/hostid...done.
 (gdb) r
 Starting program: /mybuild/hostid

 Program received signal SIGSEGV, Segmentation fault.
 0x00007ffff7f0330e in gethostid () at ../sysdeps/unix/sysv/linux/gethostid.c:125
 125   memcpy (&in, hp->h_addr,
 (gdb) bt
 #0  0x00007ffff7f0330e in gethostid () at ../sysdeps/unix/sysv/linux/gethostid.c:125
 #1  0x0000555555555159 in main ()

 # cat /mybuild/hostid.c
 #include <stdio.h>
 #include <unistd.h>

 int
 main(int argc, char *argv[])
 {
    long hostid;
    hostid = gethostid();
    printf("the hostid is %ld\n", hostid);

 }

Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/recipes-core/glibc/glibc/0001-Linux-gethostid-Check-for-NULL-value-from-gethostbyn.patch [new file with mode: 0644]
meta/recipes-core/glibc/glibc_2.28.bb