Skip to contentSkip to conversation

package/matio: add upstream security fixes

PATCH New Fabrice Fontaine 2 participants 2 messages May 2, 2020 – May 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/matio: add upstream security fixes

Fix the following CVEs:
- CVE-2019-17533: Mat_VarReadNextInfo4 in mat4.c in MATIO 1.5.17 omits a certain '\0' character, leading to a heap-based buffer over-read in strdup_vprintf when uninitialized memory is accessed.
- CVE-2019-20017: A stack-based buffer over-read was discovered in Mat_VarReadNextInfo5 in mat5.c in matio 1.5.17.
- CVE-2019-20018: A stack-based buffer over-read was discovered in ReadNextCell in mat5.c in matio 1.5.17.
- CVE-2019-20020: A stack-based buffer over-read was discovered in ReadNextStructField in mat5.c in matio 1.5.17.
- CVE-2019-20052: A memory leak was discovered in Mat_VarCalloc in mat.c in matio 1.5.17 because SafeMulDims does not consider the rank==0 case.

---
 .../0001-Avoid-uninitialized-memory.patch     | 27 +++++++++++
 .../0002-Fix-illegal-memory-access.patch      | 47 +++++++++++++++++++
 .../0003-Fix-illegal-memory-access.patch      | 46 ++++++++++++++++++
 package/matio/0004-Fix-memory-leak.patch      | 39 +++++++++++++++
 package/matio/matio.mk                        |  9 ++++
 5 files changed, 168 insertions(+)
 create mode 100644 package/matio/0001-Avoid-uninitialized-memory.patch
 create mode 100644 package/matio/0002-Fix-illegal-memory-access.patch
 create mode 100644 package/matio/0003-Fix-illegal-memory-access.patch
 create mode 100644 package/matio/0004-Fix-memory-leak.patch
package/matio/0001-Avoid-uninitialized-memory.patch new file +27 -0
new file mode 100644
index 0000000000..01fc8f0f7d
@@ -0,0 +1,27 @@
+From 651a8e28099edb5fbb9e4e1d4d3238848f446c9a Mon Sep 17 00:00:00 2001
+From: tbeu <[email protected]>
+Date: Fri, 30 Aug 2019 09:21:26 +0200
+Subject: [PATCH] Avoid uninitialized memory
+
+As reported by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16856
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Retrieved from:
+https://github.com/tbeu/matio/commit/651a8e28099edb5fbb9e4e1d4d3238848f446c9a]
+---
+ src/mat4.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/mat4.c b/src/mat4.c
+index 601a3d6..93b4308 100644
+--- a/src/mat4.c
++++ b/src/mat4.c
+@@ -917,6 +917,8 @@ Mat_VarReadNextInfo4(mat_t *mat)
+     if ( tmp != readresult ) {
+         Mat_VarFree(matvar);
+         return NULL;
++    } else {
++        matvar->name[tmp - 1] = '\0';
+     }
+ 
+     matvar->internal->datapos = ftell((FILE*)mat->fp);
package/matio/0002-Fix-illegal-memory-access.patch new file +47 -0

47 lines not on this page · raw message

package/matio/0003-Fix-illegal-memory-access.patch new file +46 -0

46 lines not on this page · raw message

package/matio/0004-Fix-memory-leak.patch new file +39 -0
new file mode 100644
index 0000000000..1899d995da
@@ -0,0 +1,39 @@
+From a47b7cd3aca70e9a0bddf8146eb4ab0cbd19c2c3 Mon Sep 17 00:00:00 2001
+From: tbeu <[email protected]>
+Date: Fri, 15 Nov 2019 23:20:41 +0100
+Subject: [PATCH] Fix memory leak
+
+As reported by https://github.com/tbeu/matio/issues/131
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Retrieved from:
+https://github.com/tbeu/matio/commit/a47b7cd3aca70e9a0bddf8146eb4ab0cbd19c2c3]
+---
+ src/mat.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/src/mat.c b/src/mat.c
+index c9c6bd1..e62a9d2 100644
+--- a/src/mat.c
++++ b/src/mat.c
+@@ -220,6 +220,11 @@ int SafeMulDims(const matvar_t *matvar, size_t* nelems)
+ {
+     int i;
+ 
++    if ( matvar->rank == 0 ) {
++        *nelems = 0;
++        return 0;
++    }
++
+     for ( i = 0; i < matvar->rank; i++ ) {
+         if ( !psnip_safe_size_mul(nelems, *nelems, matvar->dims[i]) ) {
+             *nelems = 0;
+@@ -1640,7 +1645,7 @@ Mat_VarFree(matvar_t *matvar)
+         }
+ #endif
+         if ( NULL != matvar->internal->fieldnames &&
+-             matvar->internal->num_fields > 0 ) {
++            matvar->internal->num_fields > 0 ) {
+             size_t i;
+             for ( i = 0; i < matvar->internal->num_fields; i++ ) {
+                 if ( NULL != matvar->internal->fieldnames[i] )
package/matio/matio.mk +9 -0
index 8af39ce22c..b9bb476223 100644
@@ -11,6 +11,15 @@ MATIO_LICENSE_FILES = COPYING
 MATIO_DEPENDENCIES = zlib
 MATIO_INSTALL_STAGING = YES
 
+# 0001-Avoid-uninitialized-memory.patch
+MATIO_IGNORE_CVES += CVE-2019-17533
+# 0002-Fix-illegal-memory-access.patch
+MATIO_IGNORE_CVES += CVE-2019-20017 CVE-2019-20020
+# 0003-Fix-illegal-memory-access.patch
+MATIO_IGNORE_CVES += CVE-2019-20017 CVE-2019-20018
+# 0004-Fix-memory-leak.patch
+MATIO_IGNORE_CVES += CVE-2019-20052
+
 # va_copy()
 MATIO_CONF_ENV = ac_cv_va_copy=yes
 
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 package/matio: add upstream security fixes

Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fabrice" == Fabrice Fontaine <[email protected]> writes:

Fix the following CVEs:
- CVE-2019-17533: Mat_VarReadNextInfo4 in mat4.c in MATIO 1.5.17 omits a certain '\0' character, leading to a heap-based buffer over-read in strdup_vprintf when uninitialized memory is accessed.
- CVE-2019-20017: A stack-based buffer over-read was discovered in Mat_VarReadNextInfo5 in mat5.c in matio 1.5.17.
- CVE-2019-20018: A stack-based buffer over-read was discovered in ReadNextCell in mat5.c in matio 1.5.17.
- CVE-2019-20020: A stack-based buffer over-read was discovered in ReadNextStructField in mat5.c in matio 1.5.17.
- CVE-2019-20052: A memory leak was discovered in Mat_VarCalloc in mat.c in matio 1.5.17 because SafeMulDims does not consider the rank==0 case.

Quoted 1 line

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard