From 5935caffde79be22dc9850df3d77d0e356f71a34 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 19 Sep 2024 20:10:43 +0300 Subject: [PATCH 1/3] xcur2png: fix cross-build Fixes errors caused by autoconf not finding rpl_malloc /nix/store/vl7wj0kj6rq3lgn7czb266lbr5y26kfn-aarch64-unknown-linux-gnu-binutils-2.42/bin/aarch64-unknown-linux-gnu-ld: /build/source/xcur2png.c:230:(.text+0x91c): undefined reference to `rpl_malloc' --- pkgs/tools/graphics/xcur2png/default.nix | 5 ++++ pkgs/tools/graphics/xcur2png/malloc.diff | 33 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 pkgs/tools/graphics/xcur2png/malloc.diff diff --git a/pkgs/tools/graphics/xcur2png/default.nix b/pkgs/tools/graphics/xcur2png/default.nix index 5d5396aea273..b120b501db39 100644 --- a/pkgs/tools/graphics/xcur2png/default.nix +++ b/pkgs/tools/graphics/xcur2png/default.nix @@ -11,6 +11,11 @@ stdenv.mkDerivation rec { sha256 = "0858wn2p14bxpv9lvaz2bz1rk6zk0g8zgxf8iy595m8fqv4q2fya"; }; + patches = [ + # https://github.com/eworm-de/xcur2png/pull/3 + ./malloc.diff + ]; + nativeBuildInputs = [ pkg-config ]; diff --git a/pkgs/tools/graphics/xcur2png/malloc.diff b/pkgs/tools/graphics/xcur2png/malloc.diff new file mode 100644 index 000000000000..88f4e8e17ba9 --- /dev/null +++ b/pkgs/tools/graphics/xcur2png/malloc.diff @@ -0,0 +1,33 @@ +--- a/xcur2png.c ++++ b/xcur2png.c +@@ -16,7 +16,10 @@ + /* Todo: atoi error handling */ + /* help is -h in manual */ + ++#if HAVE_CONFIG_H + #include ++#endif ++#undef malloc + + #define _ATFILE_SOURCE + #include +@@ -34,6 +37,19 @@ + #include + #include + ++ ++void *malloc (); ++ ++/* Allocate an N-byte block of memory from the heap. ++ If N is zero, allocate a 1-byte block. */ ++ ++void* rpl_malloc (size_t n) ++{ ++ if (n == 0) ++ n = 1; ++ return malloc (n); ++} ++ + #define PNG_SETJMP_NOT_SUPPORTED 1 + + #define PROGRESS_SHARPS 50 /* total number of progress sharps */ From 4cf65dda7baba339ee9412e3e116232158ae681c Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 19 Sep 2024 20:16:14 +0300 Subject: [PATCH 2/3] xcur2png: format with nixfmt-rfc-style --- pkgs/tools/graphics/xcur2png/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/graphics/xcur2png/default.nix b/pkgs/tools/graphics/xcur2png/default.nix index b120b501db39..0e9e26e3f0c7 100644 --- a/pkgs/tools/graphics/xcur2png/default.nix +++ b/pkgs/tools/graphics/xcur2png/default.nix @@ -1,4 +1,11 @@ -{ lib, stdenv, fetchFromGitHub, pkg-config, libpng, xorg }: +{ + lib, + stdenv, + fetchFromGitHub, + pkg-config, + libpng, + xorg, +}: stdenv.mkDerivation rec { pname = "xcur2png"; From 25988a2f3562a852751b116bc93d133dc286de2d Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 19 Sep 2024 21:25:45 +0300 Subject: [PATCH 3/3] xcur2png: add "fix wrong math" patch --- pkgs/tools/graphics/xcur2png/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/tools/graphics/xcur2png/default.nix b/pkgs/tools/graphics/xcur2png/default.nix index 0e9e26e3f0c7..6419752cac8a 100644 --- a/pkgs/tools/graphics/xcur2png/default.nix +++ b/pkgs/tools/graphics/xcur2png/default.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchFromGitHub, + fetchpatch, pkg-config, libpng, xorg, @@ -21,6 +22,12 @@ stdenv.mkDerivation rec { patches = [ # https://github.com/eworm-de/xcur2png/pull/3 ./malloc.diff + + # fix byte overflows due to off-by-one error + (fetchpatch { + url = "https://github.com/eworm-de/xcur2png/commit/aa035462d950fab35d322cb87fd2f0d702251e82.patch"; + hash = "sha256-hlmJ/bcDSl1ADs0jp+JrAgAaMzielUSRVPad+plnSZg="; + }) ]; nativeBuildInputs = [