summary refs log tree commit diff
path: root/pkgs/servers/x11
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2020-02-07 18:20:47 +0100
committerrnhmjoj <rnhmjoj@inventati.org>2020-02-07 18:20:47 +0100
commit1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c (patch)
tree89339684108fd52f82bf291e3ecbd1c2338601eb /pkgs/servers/x11
parent3f29e19a48ba5ae78359650c04854fd75884eaef (diff)
downloadnixpkgs-1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c.tar
nixpkgs-1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c.tar.gz
nixpkgs-1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c.tar.bz2
nixpkgs-1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c.tar.lz
nixpkgs-1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c.tar.xz
nixpkgs-1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c.tar.zst
nixpkgs-1cc11b98f15c6cf6e4012c21cbdfcc1b4279796c.zip
xorg.fonttosfnt: add patch to fix uninitialized memory bug
Diffstat (limited to 'pkgs/servers/x11')
-rw-r--r--pkgs/servers/x11/xorg/fix-uninitialised-memory.patch61
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix5
2 files changed, 66 insertions, 0 deletions
diff --git a/pkgs/servers/x11/xorg/fix-uninitialised-memory.patch b/pkgs/servers/x11/xorg/fix-uninitialised-memory.patch
new file mode 100644
index 00000000000..53f22d7f39c
--- /dev/null
+++ b/pkgs/servers/x11/xorg/fix-uninitialised-memory.patch
@@ -0,0 +1,61 @@
+From 51e8117654fb092ae5412d7aa184bfc6b498c954 Mon Sep 17 00:00:00 2001
+From: rnhmjoj <rnhmjoj@inventati.org>
+Date: Fri, 7 Feb 2020 17:46:54 +0100
+Subject: [PATCH 1/2] Fix incorrect error handling in macTime()
+
+mktime() and time() return (time_t -1) to signal an error.
+Checking for negative values will incorrectly assume an error
+happened for any calendar date before the unix epoch.
+---
+ util.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/util.c b/util.c
+index bcbfa2f..4482c9a 100644
+--- a/util.c
++++ b/util.c
+@@ -213,10 +213,10 @@ macTime(int *hi, unsigned *lo)
+     tm.tm_isdst = -1;
+ 
+     macEpoch = mktime_gmt(&tm);
+-    if(macEpoch < 0) return -1;
++    if(macEpoch == -1) return -1;
+ 
+     current = time(NULL);
+-    if(current < 0)
++    if(current == -1)
+         return -1;
+ 
+     if(current < macEpoch) {
+-- 
+2.23.0
+
+From 81a61c049e6de80120531f0770b22e7637c9acb9 Mon Sep 17 00:00:00 2001
+From: rnhmjoj <rnhmjoj@inventati.org>
+Date: Fri, 7 Feb 2020 17:47:52 +0100
+Subject: [PATCH 2/2] Fix uninitialised memory write
+
+If macTime() fails write zeros instead of unitialized memory to
+the date fields.
+---
+ write.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/write.c b/write.c
+index 318adef..c8a86e4 100644
+--- a/write.c
++++ b/write.c
+@@ -434,8 +434,8 @@ fixupChecksum(FILE *out, int full_length, int head_position)
+ static int 
+ writehead(FILE* out, FontPtr font)
+ {
+-    int time_hi;
+-    unsigned time_lo;
++    int time_hi = 0;
++    unsigned time_lo = 0;
+ 
+     macTime(&time_hi, &time_lo);
+ 
+-- 
+2.23.0
+
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index 7a9ffcfc646..2261831586a 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -22,6 +22,11 @@ self: super:
     buildInputs = attrs.buildInputs ++ [ self.xorgproto ];
   });
 
+  fonttosfnt = super.fonttosfnt.overrideAttrs (attrs: {
+    # https://gitlab.freedesktop.org/xorg/app/fonttosfnt/merge_requests/6
+    patches = [ ./fix-uninitialised-memory.patch ];
+  });
+
   bitmap = super.bitmap.overrideAttrs (attrs: {
     nativeBuildInputs = attrs.nativeBuildInputs ++ [ makeWrapper ];
     postInstall = ''