diff --git a/.gitignore b/.gitignore index 1ae6447..838662a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/python-dmidecode-3.10.13.tar.xz +SOURCES/python-dmidecode-3.12.2.tar.xz diff --git a/.python-dmidecode.metadata b/.python-dmidecode.metadata index 28d59f7..74e7550 100644 --- a/.python-dmidecode.metadata +++ b/.python-dmidecode.metadata @@ -1 +1 @@ -e3473db49f81b30aa50f4e05c9a91512399788ab SOURCES/python-dmidecode-3.10.13.tar.xz +47d26ffcc5a3a6d846568138bce7b3a15f352c13 SOURCES/python-dmidecode-3.12.2.tar.xz diff --git a/SOURCES/0001-Harden-dmi_string-calls-with-better-NULL-checks.patch b/SOURCES/0001-Harden-dmi_string-calls-with-better-NULL-checks.patch deleted file mode 100644 index 2ff61a7..0000000 --- a/SOURCES/0001-Harden-dmi_string-calls-with-better-NULL-checks.patch +++ /dev/null @@ -1,126 +0,0 @@ -From d6987c53d3648d85e410ef81a343867e239eb960 Mon Sep 17 00:00:00 2001 -From: David Sommerseth -Date: Thu, 6 Jan 2011 15:56:24 +0100 -Subject: [PATCH 1/1] Harden dmi_string() calls with better NULL checks - -This patch fixes more potential issues where dmi_string() results -was not necessarily checked for NULL, which potentially could lead -to SEGV issues. - -Signed-off-by: David Sommerseth ---- - src/dmidecode.c | 23 ++++++++++++++++------- - src/dmioem.c | 13 +++++++++++-- - src/dmioem.h | 2 +- - 3 files changed, 28 insertions(+), 10 deletions(-) - -diff --git a/src/dmidecode.c b/src/dmidecode.c -index 726b2de..17f2130 100644 ---- a/src/dmidecode.c -+++ b/src/dmidecode.c -@@ -918,6 +918,11 @@ void dmi_processor_family(xmlNode *node, const struct dmi_header *h) - /* Special case for ambiguous value 0xBE */ - if(code == 0xBE) { - const char *manufacturer = dmi_string(h, data[0x07]); -+ -+ if( manufacturer == NULL ) { -+ dmixml_AddTextContent(family_n, "Core 2 or K7 (Unkown manufacturer)"); -+ return; -+ } - - /* Best bet based on manufacturer string */ - if(strstr(manufacturer, "Intel") != NULL || -@@ -931,7 +935,7 @@ void dmi_processor_family(xmlNode *node, const struct dmi_header *h) - dmixml_AddTextContent(family_n, "K7"); - return; - } -- dmixml_AddTextContent(family_n, "Core 2 or K7"); -+ dmixml_AddTextContent(family_n, "Core 2 or K7 (Unkown manufacturer)"); - return; - } - -@@ -959,7 +963,7 @@ void dmi_processor_family(xmlNode *node, const struct dmi_header *h) - dmixml_AddAttribute(family_n, "outofspec", "1"); - } - --xmlNode *dmi_processor_id(xmlNode *node, u8 type, const u8 * p, const char *version) -+xmlNode *dmi_processor_id(xmlNode *node, const struct dmi_header *h) - { - /* Intel AP-485 revision 31, table 3-4 */ - static struct _cpuflags { -@@ -1001,11 +1005,18 @@ xmlNode *dmi_processor_id(xmlNode *node, u8 type, const u8 * p, const char *vers - {"PBE", "PBE (Pending break enabled)"} /* 31 */ - /* *INDENT-ON* */ - }; -+ u8 type, *p = NULL; -+ char *version = NULL; - - xmlNode *flags_n = NULL; - xmlNode *data_n = xmlNewChild(node, NULL, (xmlChar *) "CPUCore", NULL); - assert( data_n != NULL ); - -+ assert( h && h->data ); -+ type = h->data[0x06]; -+ p = h->data + 8; -+ version = dmi_string(h, h->data[0x10]); -+ - /* - ** Extra flags are now returned in the ECX register when one calls - ** the CPUID instruction. Their meaning is explained in table 3-5, but -@@ -3878,7 +3889,7 @@ xmlNode *dmi_decode(xmlNode *prnt_n, dmi_codes_major *dmiMajor, struct dmi_heade - dmi_processor_type(sect_n, data[0x05]); - dmi_processor_family(sect_n, h); - -- dmi_processor_id(sect_n, data[0x06], data + 8, dmi_string(h, data[0x10])); -+ dmi_processor_id(sect_n, h); - - sub_n = xmlNewChild(sect_n, NULL, (xmlChar *) "Manufacturer", NULL); - assert( sub_n != NULL ); -@@ -4899,7 +4909,7 @@ static void dmi_table(Log_t *logp, int type, u32 base, u16 len, u16 num, u16 ver - - /* assign vendor for vendor-specific decodes later */ - if(h.type == 0 && h.length >= 5) { -- dmi_set_vendor(dmi_string(&h, data[0x04])); -+ dmi_set_vendor(&h); - } - - /* look for the next handle */ -diff --git a/src/dmioem.c b/src/dmioem.c -index 361810a..67cd517 100644 ---- a/src/dmioem.c -+++ b/src/dmioem.c -@@ -40,10 +40,19 @@ static enum DMI_VENDORS dmi_vendor = VENDOR_UNKNOWN; - * value if we know how to decode at least one specific entry type for - * that vendor. - */ --void dmi_set_vendor(const char *s) -+void dmi_set_vendor(const struct dmi_header *h) - { -- if(strcmp(s, "HP") == 0) -+ const char *vendor; -+ -+ if( !h || !h->data ) { -+ return; -+ } -+ vendor = dmi_string(h, h->data[0x04]); -+ if( !vendor ) { -+ return; -+ } else if(strcmp(vendor, "HP") == 0) { - dmi_vendor = VENDOR_HP; -+ } - } - - /* -diff --git a/src/dmioem.h b/src/dmioem.h -index b1b4af8..9ad25bf 100644 ---- a/src/dmioem.h -+++ b/src/dmioem.h -@@ -22,5 +22,5 @@ - - struct dmi_header; - --void dmi_set_vendor(const char *s); -+void dmi_set_vendor(const struct dmi_header *h); - int dmi_decode_oem(struct dmi_header *h); --- -1.8.3.1 diff --git a/SOURCES/SIGILL-catcher.patch b/SOURCES/SIGILL-catcher.patch deleted file mode 100644 index f99e474..0000000 --- a/SOURCES/SIGILL-catcher.patch +++ /dev/null @@ -1,122 +0,0 @@ -diff --git a/src/util.c b/src/util.c -index 2eebf30..4d1be64 100644 ---- a/src/util.c -+++ b/src/util.c -@@ -44,6 +44,7 @@ - #include - #include - #include -+#include - - #include "types.h" - #include "util.h" -@@ -87,6 +88,23 @@ int checksum(const u8 * buf, size_t len) - return (sum == 0); - } - -+/* Static global variables which should only -+ * be used by the sigill_handler() -+ */ -+static int sigill_error = 0; -+static Log_t *sigill_logobj = NULL; -+ -+void sigill_handler(int ignore_this) { -+ sigill_error = 1; -+ if( sigill_logobj ) { -+ log_append(sigill_logobj, LOGFL_NODUPS, LOG_WARNING, -+ "SIGILL signal caught in mem_chunk()"); -+ } else { -+ fprintf(stderr, -+ "** WARNING ** SIGILL signal caught in mem_chunk()\n"); -+ } -+} -+ - /* - * Copy a physical memory chunk into a memory buffer. - * This function allocates memory. -@@ -100,15 +118,20 @@ void *mem_chunk(Log_t *logp, size_t base, size_t len, const char *devmem) - size_t mmoffset; - void *mmp; - #endif -- -- if((fd = open(devmem, O_RDONLY)) == -1) { -- log_append(logp, LOGFL_NORMAL, LOG_WARNING, "%s: %s", devmem, strerror(errno)); -- return NULL; -+ sigill_logobj = logp; -+ signal(SIGILL, sigill_handler); -+ if(sigill_error || (fd = open(devmem, O_RDONLY)) == -1) { -+ log_append(logp, LOGFL_NORMAL, LOG_WARNING, -+ "Failed to open memory buffer (%s): %s", -+ devmem, strerror(errno)); -+ p = NULL; -+ goto exit; - } - -- if((p = malloc(len)) == NULL) { -- log_append(logp, LOGFL_NORMAL, LOG_WARNING, "malloc: %s", strerror(errno)); -- return NULL; -+ if(sigill_error || (p = malloc(len)) == NULL) { -+ log_append(logp, LOGFL_NORMAL, LOG_WARNING,"malloc: %s", strerror(errno)); -+ p = NULL; -+ goto exit; - } - #ifdef USE_MMAP - #ifdef _SC_PAGESIZE -@@ -122,33 +145,49 @@ void *mem_chunk(Log_t *logp, size_t base, size_t len, const char *devmem) - * to read from /dev/mem using regular read() calls. - */ - mmp = mmap(0, mmoffset + len, PROT_READ, MAP_SHARED, fd, base - mmoffset); -- if(mmp == MAP_FAILED) { -+ if(sigill_error || (mmp == MAP_FAILED)) { - log_append(logp, LOGFL_NORMAL, LOG_WARNING, "%s (mmap): %s", devmem, strerror(errno)); - free(p); -- return NULL; -+ p = NULL; -+ goto exit; - } - - memcpy(p, (u8 *) mmp + mmoffset, len); -- -- if(munmap(mmp, mmoffset + len) == -1) { -+ if (sigill_error) { -+ log_append(logp, LOGFL_NODUPS, LOG_WARNING, -+ "Failed to do memcpy() due to SIGILL signal"); -+ free(p); -+ p = NULL; -+ goto exit; -+ } -+ -+ if(sigill_error || (munmap(mmp, mmoffset + len) == -1)) { - log_append(logp, LOGFL_NORMAL, LOG_WARNING, "%s (munmap): %s", devmem, strerror(errno)); -+ free(p); -+ p = NULL; -+ goto exit; - } - #else /* USE_MMAP */ -- if(lseek(fd, base, SEEK_SET) == -1) { -+ if(sigill_error || (lseek(fd, base, SEEK_SET) == -1)) { - log_append(logp, LOGFL_NORMAL, LOG_WARNING, "%s (lseek): %s", devmem, strerror(errno)); - free(p); -- return NULL; -+ p = NULL; -+ goto exit; - } - -- if(myread(logp, fd, p, len, devmem) == -1) { -+ if(sigill_error || (myread(logp, fd, p, len, devmem) == -1)) { - free(p); -- return NULL; -+ p = NULL; -+ goto exit; - } - #endif /* USE_MMAP */ - - if(close(fd) == -1) - perror(devmem); - -+ exit: -+ signal(SIGILL, SIG_DFL); -+ sigill_logobj = NULL; - return p; - } - diff --git a/SOURCES/disable-old-smbios-warning.patch b/SOURCES/disable-old-smbios-warning.patch new file mode 100644 index 0000000..88b183a --- /dev/null +++ b/SOURCES/disable-old-smbios-warning.patch @@ -0,0 +1,15 @@ +--- a/src/dmidecode.c 2017-03-13 10:29:05.482568934 +0100 ++++ b/src/dmidecode.c 2017-03-13 10:29:21.437336606 +0100 +@@ -5230,12 +5230,6 @@ static void dmi_table(Log_t *logp, int t + return; + } + +- if (ver > SUPPORTED_SMBIOS_VER) { +- log_append(logp, LOGFL_NODUPS, LOG_WARNING, +- "# SMBIOS implementations newer than version %u.%u are not\n" +- "# fully supported by this version of dmidecode.\n", +- SUPPORTED_SMBIOS_VER >> 8, SUPPORTED_SMBIOS_VER & 0xFF); +- } + // FIXME: This is hackerish ... rather try to avoid looping dmi_table() calls too much + if( version_added == 0 ) { + dmixml_AddAttribute(xmlnode, "smbios_version", "%u.%u", ver >> 8, ver & 0xFF); diff --git a/SOURCES/dmispec-remove.patch b/SOURCES/dmispec-remove.patch deleted file mode 100644 index 76a0191..0000000 --- a/SOURCES/dmispec-remove.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 39869fb9346cd46097bd6d70a90f351938d30296 Mon Sep 17 00:00:00 2001 -From: David Sommerseth -Date: Fri, 5 Apr 2013 18:25:23 +0200 -Subject: [PATCH 1/2] Do not add explictly 'dmispec' attributes inside - switch() in dmi_decode() - -The dmispec attribute is added outside the switch() call, and must not be -duplicated. If this happens, an invalid XML file will be generated. -(Un)fortunately, libxml2 is quite forgiving to this error. But xmllint -will complain about it and other XML libraries (such as python-lxml) -may reject such XML data. - -Signed-off-by: David Sommerseth ---- - src/dmidecode.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/src/dmidecode.c b/src/dmidecode.c -index 17f2130..215c3f4 100644 ---- a/src/dmidecode.c -+++ b/src/dmidecode.c -@@ -4784,7 +4784,6 @@ xmlNode *dmi_decode(xmlNode *prnt_n, dmi_codes_major *dmiMajor, struct dmi_heade - - case 40: /* 3.3.41 Additional Information */ - dmixml_AddAttribute(sect_n, "subtype", "AdditionalInformation"); -- dmixml_AddAttribute(sect_n, "dmispec", "3.3.41"); - - if(h->length < 0x0B) { - break; -@@ -4795,7 +4794,6 @@ xmlNode *dmi_decode(xmlNode *prnt_n, dmi_codes_major *dmiMajor, struct dmi_heade - - case 41: /* 3.3.42 Onboard Device Extended Information */ - dmixml_AddAttribute(sect_n, "subtype", "OnboardDeviceExtendedInformation"); -- dmixml_AddAttribute(sect_n, "dmispec", "3.3.42"); - - if(h->length < 0x0B) { - break; --- -1.7.10.2 diff --git a/SOURCES/installed-invalid.patch b/SOURCES/installed-invalid.patch deleted file mode 100644 index e318883..0000000 --- a/SOURCES/installed-invalid.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 69a1c9ca658c9708698cde6aee32af7bb2e16f9a Mon Sep 17 00:00:00 2001 -From: David Sommerseth -Date: Thu, 20 Jun 2013 12:58:12 +0200 -Subject: [PATCH] Fixed a missing break statement in a switch for DMI section - 3.3.7.2 - -This missing break could cause duplicated 'installed' attributes in - or XML tags. This is only happening -when dmi_memory_module_size() is called and only on some hardware. - -Signed-off-by: David Sommerseth ---- - src/dmidecode.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/dmidecode.c b/src/dmidecode.c -index 215c3f4..dae2fef 100644 ---- a/src/dmidecode.c -+++ b/src/dmidecode.c -@@ -1516,6 +1516,7 @@ void dmi_memory_module_size(xmlNode *node, const char *tagname, u8 code) - case 0x7F: - dmixml_AddAttribute(data_n, "installed", "0"); - check_conn = 0; -+ break; - default: - dmixml_AddAttribute(data_n, "installed", "1"); - dmixml_AddAttribute(data_n, "unit", "MB"); --- -1.7.10.2 - - diff --git a/SPECS/python-dmidecode.spec b/SPECS/python-dmidecode.spec index b41a809..94176d7 100644 --- a/SPECS/python-dmidecode.spec +++ b/SPECS/python-dmidecode.spec @@ -3,8 +3,8 @@ Summary: Python module to access DMI data Name: python-dmidecode -Version: 3.10.13 -Release: 12%{?dist} +Version: 3.12.2 +Release: 1%{?dist} License: GPLv2 Group: System Environment/Libraries URL: http://projects.autonomy.net.au/python-dmidecode/ @@ -16,13 +16,7 @@ BuildRequires: libxml2-python BuildRequires: libxml2-devel BuildRequires: python-devel -# already in restored upstream git -Patch1: SIGILL-catcher.patch -# email: upstream why not in git, planed for release -Patch2: dmispec-remove.patch -# email: git postponed but planned for release -Patch3: installed-invalid.patch -Patch4: 0001-Harden-dmi_string-calls-with-better-NULL-checks.patch +Patch0: disable-old-smbios-warning.patch %description python-dmidecode is a python extension module that uses the @@ -31,10 +25,7 @@ as python data structures or as XML data using libxml2. %prep %setup -q -%patch1 -p1 -b .SIGILL-catcher -%patch2 -p1 -b .dmispec-remove -%patch3 -p1 -b .install-invalid -%patch4 -p1 +%patch0 -p1 %build make build @@ -62,9 +53,9 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/python-dmidecode/ %changelog -* Mon May 22 2017 Petr Oros - 3.10.13-12 -- Fix segfaults when reading invalid dmidecode data -- Resolves: #1431702 +* Mon Mar 13 2017 Petr Oros - 3.12.2-1 +- Update to new release +- Resolves: #1431548 * Fri Jan 24 2014 Daniel Mach - 3.10.13-11 - Mass rebuild 2014-01-24