[Midnightbsd-cvs] src [8891] trunk/lib/libelf: make sure to set an error code when trying to obtain a data desc for a section of ype SHT_NULL
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Mon Sep 26 18:30:05 EDT 2016
Revision: 8891
http://svnweb.midnightbsd.org/src/?rev=8891
Author: laffer1
Date: 2016-09-26 18:30:05 -0400 (Mon, 26 Sep 2016)
Log Message:
-----------
make sure to set an error code when trying to obtain a data desc for a section of ype SHT_NULL
Modified Paths:
--------------
trunk/lib/libelf/elf_data.c
trunk/lib/libelf/elf_getdata.3
Modified: trunk/lib/libelf/elf_data.c
===================================================================
--- trunk/lib/libelf/elf_data.c 2016-09-26 22:27:57 UTC (rev 8890)
+++ trunk/lib/libelf/elf_data.c 2016-09-26 22:30:05 UTC (rev 8891)
@@ -78,8 +78,10 @@
sh_align = s->s_shdr.s_shdr64.sh_addralign;
}
- if (sh_type == SHT_NULL)
+ if (sh_type == SHT_NULL) {
+ LIBELF_SET_ERROR(SECTION, 0);
return (NULL);
+ }
if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST ||
elftype > ELF_T_LAST || (sh_type != SHT_NOBITS &&
@@ -219,8 +221,10 @@
sh_align = s->s_shdr.s_shdr64.sh_addralign;
}
- if (sh_type == SHT_NULL)
+ if (sh_type == SHT_NULL) {
+ LIBELF_SET_ERROR(SECTION, 0);
return (NULL);
+ }
if ((d = _libelf_allocate_data(s)) == NULL)
return (NULL);
Modified: trunk/lib/libelf/elf_getdata.3
===================================================================
--- trunk/lib/libelf/elf_getdata.3 2016-09-26 22:27:57 UTC (rev 8890)
+++ trunk/lib/libelf/elf_getdata.3 2016-09-26 22:30:05 UTC (rev 8891)
@@ -23,7 +23,7 @@
.\"
.\" $MidnightBSD$
.\"
-.Dd January 26, 2011
+.Dd February 18, 2013
.Dt ELF_GETDATA 3
.Os
.Sh NAME
@@ -186,6 +186,23 @@
.Ar scn .
.It Bq Er ELF_E_RESOURCE
An out of memory condition was detected.
+.It Bq Er ELF_E_SECTION
+Section
+.Ar scn
+had type
+.Dv SHT_NULL .
+.It Bq Er ELF_E_SECTION
+The type of the section
+.Ar scn
+was not recognized by the library.
+.It Bq Er ELF_E_SECTION
+The size of the section
+.Ar scn
+is not a multiple of the file size for its section type.
+.It Bq Er ELF_E_SECTION
+The file offset for section
+.Ar scn
+is incorrect.
.El
.Sh SEE ALSO
.Xr elf 3 ,
More information about the Midnightbsd-cvs
mailing list