guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: gnu: libhx: Fix runtime bug.


From: guix-commits
Subject: 01/02: gnu: libhx: Fix runtime bug.
Date: Wed, 13 Oct 2021 08:57:30 -0400 (EDT)

glv pushed a commit to branch master
in repository guix.

commit c1ea1a94c33035a5aec413617d502884647af628
Author: Guillaume Le Vaillant <glv@posteo.net>
AuthorDate: Tue Oct 12 16:43:40 2021 +0200

    gnu: libhx: Fix runtime bug.
    
    There is a bug in libhx causing pam-mount to crash when trying to mount user
    directories at login. Upstream has a patch to fix this issue.
    
    * gnu/packages/patches/libhx-fix-double-free-bug.patch: New file.
    * gnu/local.mk (dist_patch_DATA): Add it.
    * gnu/packages/c.scm (libhx)[source]: Use it.
---
 gnu/local.mk                                       |  3 +-
 gnu/packages/c.scm                                 |  5 +-
 .../patches/libhx-fix-double-free-bug.patch        | 80 ++++++++++++++++++++++
 3 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index c0734c3..6f03793 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -20,7 +20,7 @@
 # Copyright © 2018, 2019, 2020, 2021 Oleg Pykhalov <go.wigust@gmail.com>
 # Copyright © 2018 Stefan Stefanović <stefanx2ovic@gmail.com>
 # Copyright © 2018, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
-# Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net>
+# Copyright © 2019, 2020, 2021 Guillaume Le Vaillant <glv@posteo.net>
 # Copyright © 2019, 2020 John Soo <jsoo1@asu.edu>
 # Copyright © 2019 Jonathan Brielmaier <jonathan.brielmaier@web.de>
 # Copyright © 2019 Evan Straw <evan.straw99@gmail.com>
@@ -1379,6 +1379,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/libgnome-encoding.patch                 \
   %D%/packages/patches/libgnomeui-utf8.patch                   \
   %D%/packages/patches/libgrss-CVE-2016-2001.patch             \
+  %D%/packages/patches/libhx-fix-double-free-bug.patch         \
   %D%/packages/patches/libjxr-fix-function-signature.patch     \
   %D%/packages/patches/libjxr-fix-typos.patch                  \
   %D%/packages/patches/libofa-ftbfs-1.diff             \
diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index 7fdac40..9f30295 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -4,7 +4,7 @@
 ;;; Copyright © 2018, 2020, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018, 2019 Pierre Neidhardt <mail@ambrevar.xyz>
 ;;; Copyright © 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2019, 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020, 2021 Marius Bakke <marius@gnu.org>
@@ -259,7 +259,8 @@ whose behaviour is inconsistent across *NIX flavours.")
        (uri (string-append "https://inai.de/files/libhx/";
                            "libHX-" version ".tar.xz"))
        (sha256
-        (base32 "1f4rmarym1j368cbxhqzyvdn5dk4bh8951s19ffqwql16anqsgfr"))))
+        (base32 "1f4rmarym1j368cbxhqzyvdn5dk4bh8951s19ffqwql16anqsgfr"))
+       (patches (search-patches "libhx-fix-double-free-bug.patch"))))
     (build-system gnu-build-system)
     (home-page "https://inai.de/projects/libhx/";)
     (synopsis "C library with common data structures and functions")
diff --git a/gnu/packages/patches/libhx-fix-double-free-bug.patch 
b/gnu/packages/patches/libhx-fix-double-free-bug.patch
new file mode 100644
index 0000000..80c2c6c
--- /dev/null
+++ b/gnu/packages/patches/libhx-fix-double-free-bug.patch
@@ -0,0 +1,80 @@
+From a08eabc6e5a3e0a9c7a15ca15ff7d450ecb6db88 Mon Sep 17 00:00:00 2001
+From: Jan Engelhardt <jengelh@inai.de>
+Date: Tue, 12 Oct 2021 17:32:43 +0200
+Subject: [PATCH] io: fix a use-after-free in conjunction with HX_realpath
+
+HX_readlink(&x, ...) forgot to set x to nullptr upon error, which
+trips up subsequent calls to HX_readlink with the very same x.
+
+Fixes: v3.26-1-g97f4be2
+---
+ src/io.c          |  8 ++++++--
+ src/tc-realpath.c | 10 ++++++++++
+ 2 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/src/io.c b/src/io.c
+index 95d6fd6..14078fc 100644
+--- a/src/io.c
++++ b/src/io.c
+@@ -316,8 +316,10 @@ EXPORT_SYMBOL int HX_readlink(hxmc_t **target, const char 
*path)
+               ssize_t ret = readlink(path, *target, linkbuf_size);
+               if (ret < 0) {
+                       int saved_errno = errno;
+-                      if (allocate)
++                      if (allocate) {
+                               HXmc_free(*target);
++                              *target = nullptr;
++                      }
+                       return -(errno = saved_errno);
+               }
+               if (static_cast(size_t, ret) < linkbuf_size) {
+@@ -327,8 +329,10 @@ EXPORT_SYMBOL int HX_readlink(hxmc_t **target, const char 
*path)
+               linkbuf_size *= 2;
+               if (HXmc_setlen(target, linkbuf_size) == NULL) {
+                       int saved_errno = errno;
+-                      if (allocate)
++                      if (allocate) {
+                               HXmc_free(*target);
++                              *target = nullptr;
++                      }
+                       return -(errno = saved_errno);
+               }
+       }
+diff --git a/src/tc-realpath.c b/src/tc-realpath.c
+index 5dd9aa2..c2ef15a 100644
+--- a/src/tc-realpath.c
++++ b/src/tc-realpath.c
+@@ -11,6 +11,7 @@
+ #include <stdlib.h>
+ #include <libHX/io.h>
+ #include <libHX/option.h>
++#include <libHX/string.h>
+ 
+ static unsigned int rp_flags;
+ static unsigned int rp_absolute;
+@@ -42,6 +43,14 @@ static bool rp_get_options(int *argc, const char ***argv)
+       return true;
+ }
+ 
++static void t_1(void)
++{
++      hxmc_t *tmp = HXmc_strinit("");
++      /* two components, so that HX_readlink gets called twice */
++      HX_realpath(&tmp, "/dev/tty", HX_REALPATH_DEFAULT);
++      HXmc_free(tmp);
++}
++
+ int main(int argc, const char **argv)
+ {
+       hxmc_t *res;
+@@ -49,6 +58,7 @@ int main(int argc, const char **argv)
+ 
+       if (!rp_get_options(&argc, &argv))
+               return EXIT_FAILURE;
++      t_1();
+ 
+       res = NULL;
+       while (--argc > 0) {
+-- 
+2.33.0
+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]