aboutsummaryrefslogtreecommitdiff
https://github.com/gnuaspell/aspell/commit/0718b375425aad8e54e1150313b862e4c6fd324a
https://nvd.nist.gov/vuln/detail/CVE-2019-25051

From 0718b375425aad8e54e1150313b862e4c6fd324a Mon Sep 17 00:00:00 2001
From: Kevin Atkinson <kevina@gnu.org>
Date: Sat, 21 Dec 2019 20:32:47 +0000
Subject: [PATCH] objstack: assert that the alloc size will fit within a chunk
 to prevent a buffer overflow

Bug found using OSS-Fuze.
---
 common/objstack.hpp | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/common/objstack.hpp b/common/objstack.hpp
index 3997bf7..bd97ccd 100644
--- a/common/objstack.hpp
+++ b/common/objstack.hpp
@@ -5,6 +5,7 @@
 #include "parm_string.hpp"
 #include <stdlib.h>
 #include <assert.h>
+#include <stddef.h>
 
 namespace acommon {
 
@@ -26,6 +27,12 @@ class ObjStack
   byte * temp_end;
   void setup_chunk();
   void new_chunk();
+  bool will_overflow(size_t sz) const {
+    return offsetof(Node,data) + sz > chunk_size;
+  }
+  void check_size(size_t sz) {
+    assert(!will_overflow(sz));
+  }
 
   ObjStack(const ObjStack &);
   void operator=(const ObjStack &);
@@ -56,7 +63,7 @@ class ObjStack
   void * alloc_bottom(size_t size)  {
     byte * tmp = bottom;
     bottom += size;
-    if (bottom > top) {new_chunk(); tmp = bottom; bottom += size;}
+    if (bottom > top) {check_size(size); new_chunk(); tmp = bottom; bottom += size;}
     return tmp;
   }
   // This alloc_bottom will insure that the object is aligned based on the
@@ -66,7 +73,7 @@ class ObjStack
     align_bottom(align);
     byte * tmp = bottom;
     bottom += size;
-    if (bottom > top) {new_chunk(); goto loop;}
+    if (bottom > top) {check_size(size); new_chunk(); goto loop;}
     return tmp;
   }
   char * dup_bottom(ParmString str) {
@@ -79,7 +86,7 @@ class ObjStack
   // always be aligned as such.
   void * alloc_top(size_t size) {
     top -= size;
-    if (top < bottom) {new_chunk(); top -= size;}
+    if (top < bottom) {check_size(size); new_chunk(); top -= size;}
     return top;
   }
   // This alloc_top will insure that the object is aligned based on
@@ -88,7 +95,7 @@ class ObjStack
   {loop:
     top -= size;
     align_top(align);
-    if (top < bottom) {new_chunk(); goto loop;}
+    if (top < bottom) {check_size(size); new_chunk(); goto loop;}
     return top;
   }
   char * dup_top(ParmString str) {
@@ -117,6 +124,7 @@ class ObjStack
   void * alloc_temp(size_t size) {
     temp_end = bottom + size;
     if (temp_end > top) {
+      check_size(size);
       new_chunk();
       temp_end = bottom + size;
     }
@@ -131,6 +139,7 @@ class ObjStack
     } else {
       size_t s = temp_end - bottom;
       byte * p = bottom;
+      check_size(size);
       new_chunk();
       memcpy(bottom, p, s);
       temp_end = bottom + size;
@@ -150,6 +159,7 @@ class ObjStack
     } else {
       size_t s = temp_end - bottom;
       byte * p = bottom;
+      check_size(size);
       new_chunk();
       memcpy(bottom, p, s);
       temp_end = bottom + size;
d8f61ee59b0ee9c2f6eb5fede09782052'>gnu: cairo: Remove labels and use gexps....* gnu/packages/gtk.scm (cairo) [arguments] <configure-flags>: Use gexps. [native-inputs, inputs]: Remove labels. Change-Id: Ifc4d9435bc1e203ee4427452ad26dedbac2de9fc Maxim Cournoyer 2024-08-31gnu: perl-gtk3: Remove input labels....* gnu/packages/gtk.scm (perl-gtk3) [native-inputs]: Remove input labels. Change-Id: Iaf289d8610df9658b83008c898781822a3cd462e Maxim Cournoyer 2024-08-31gnu: goocanvas: Remove input labels....* gnu/packages/gtk.scm (goocanvas) [native-inputs]: Remove input labels. [phases]: Remove trailing #t. Change-Id: I0eca2aeb1e01b81e89a0777fb806539d8a76972b Maxim Cournoyer 2024-08-31gnu: gtkmm: Remove input labels....* gnu/packages/gtk.scm (gtkmm) [native-inputs]: Remove input labels. Change-Id: I7dad8ada8d32c25845877aba0fc68245ff001a7e Maxim Cournoyer 2024-08-31gnu: atkmm: Remove input labels....* gnu/packages/gtk.scm (atkmm) [native-inputs]: Remove input labels. Change-Id: I7dad8ada8d32c25845877aba0fc68245ff001a7e Maxim Cournoyer 2024-08-31gnu: gtkmm-3: Update to 3.24.8....* gnu/packages/gtk.scm (gtkmm-3): Update to 3.24.8. [propagated-inputs]: Remove labels. Change-Id: I5cda1f2a3c211f766c649e23a33f48c277c615d8 Maxim Cournoyer 2024-08-31gnu: gtk-doc: Add 'bash' input for 'wrap-program'....It is required for cross-compilation. * gnu/packages/gtk.scm (gtk-doc)[inputs]: Add 'bash-minimal'. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Change-Id: I5db498ba4c7c7db239adb2b46a16585da044fd02 Maxime Devos 2024-08-31gnu: gtk-doc: Remove leftovers....No longer needed, package passes tests without these parameters. * gnu/packages/gtk.scm (gtk-doc)[arguments]<#:parallel-tests?>: Re-enable. <#:phases>: Remove 'disable-failing-tests. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Bruno Victal 2024-08-31gnu: gtk-doc: Wrap XML_CATALOG_FILES....Prefer XML catalog resolution over substitutions on XML files. * gnu/packages/gtk.scm (gtk-doc)[arguments]<#:phases>: Remove 'patch-gtk-doc-scan. Wrap XML_CATALOG_FILES within 'wrap-executables. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Bruno Victal 2024-08-31gnu: gtk-doc: Rewrite with G-Expressions....* gnu/packages/gtk.scm (gtk-doc): Rewrite with G-Expressions. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Bruno Victal 2024-08-31gnu: gtk: Drop docbook workaround....* gnu/packages/gtk.scm (gtk)[arguments]<#:phases>: Drop docbook workaround. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Bruno Victal 2024-08-31gnu: gtk-doc: Add libxslt native-search-paths to its own....Grepping through the built package, gtk-doc invokes 'xsltproc' so we add %libxslt-search-paths to native-search-paths in order for 'xsltproc' to find the XML/SGML catalog files. * gnu/packages/gtk.scm (gtk-doc)[native-search-paths]: Add %libxslt-search-paths. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Bruno Victal 2024-08-25gnu: Drop gobject-introspection 1.73.1....The actual gobject-introspection has been newer than its "next" variant for some while. * gnu/packages/glib.scm (gobject-introspection-next): Remove variable. * gnu/packages/gtk.scm (gtksourceview)[native-inputs]: Replace gobject-introspection-next with gobject-introspection. * gnu/packages/guile-xyz.scm (guile-g-golf)[native-inputs]: Likewise. Liliana Marie Prikler