Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Feh's right-click buffer overflow crash #259649

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

CharlzKlug
Copy link
Contributor

@CharlzKlug CharlzKlug commented Oct 7, 2023

Description of changes

Added a patch for fix the right-click crash. #258444

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@FliegendeWurst
Copy link
Member

Thanks for the fix.
Please change the commit message so it follows the guidelines in https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md.
Also link your PR derf/feh#723 in a comment next to the patch.

@CharlzKlug
Copy link
Contributor Author

Also link your PR derf/feh#723 in a comment next to the patch.

Thank you for your reply! Sorry, I can't understand where I should link my PR. Can you give me a clue?

@FliegendeWurst
Copy link
Member

FliegendeWurst commented Oct 19, 2023

Looks good now, thank you. Please squash your commits (see here if you don't know how).

Result of nixpkgs-review on x86_64-linux: ✔️

9 packages updated:
deco-unstable farge feh multilockscreen python3.10-pywal python3.11-pywal pywal stylish-unstable wpgtk
13 packages built:
deco farge feh feh.doc feh.man multilockscreen pywal pywal.dist python311Packages.pywal python311Packages.pywal.dist stylish wpgtk wpgtk.dist

@CharlzKlug
Copy link
Contributor Author

CharlzKlug commented Oct 19, 2023

Looks good now, thank you. Please squash your commits (see here if you don't know how).

I have tried to squash the commits. Is it good?

Copy link
Contributor

@eclairevoyant eclairevoyant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easily reproducible crash and the patch does indeed fix it. Thanks for the contribution!

@CharlzKlug
Copy link
Contributor Author

Easily reproducible crash and the patch does indeed fix it. Thanks for the contribution!

You are welcome!

@Artturin
Copy link
Member

Artturin commented Nov 18, 2023

We prefer to fetchpatch patches when there's an upstream PR, I've switched to fetchpatch for you.
NVM I can't push to this branch because you're making a PR from the master branch of your fork.

Please apply

diff --git a/pkgs/applications/graphics/feh/0001-Right-click-crash-fix.patch b/pkgs/applications/graphics/feh/0001-Right-click-crash-fix.patch
deleted file mode 100644
index ce3266fb8691..000000000000
--- a/pkgs/applications/graphics/feh/0001-Right-click-crash-fix.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 2c31f8863b80030e772a529ade519fc2fee4a991 Mon Sep 17 00:00:00 2001
-From: Ametov Imil <charlz_klug@mail.ru>
-Date: Fri, 6 Oct 2023 00:03:58 +0300
-Subject: [PATCH] Fix for right-click buffer overflow
-
----
- src/menu.c | 16 ++++++----------
- 1 file changed, 6 insertions(+), 10 deletions(-)
-
-diff --git a/src/menu.c b/src/menu.c
-index 455ed19b..b1ef61d0 100644
---- a/src/menu.c
-+++ b/src/menu.c
-@@ -825,21 +825,17 @@ void feh_menu_draw_toggle_at(int x, int y, int w, int h, Imlib_Image dst, int ox
- 
- void feh_menu_draw_submenu_at(int x, int y, Imlib_Image dst, int ox, int oy)
- {
--	ImlibPolygon poly;
--
--	x -= ox;
-+        // Draw filled triangle
-+        x -= ox;
- 	y -= oy;
- 
- 	imlib_context_set_image(dst);
--
--	poly = imlib_polygon_new();
--	imlib_polygon_add_point(poly, x, y + 3);
--	imlib_polygon_add_point(poly, x + 3, y + 6);
--	imlib_polygon_add_point(poly, x, y + 9);
- 	imlib_context_set_color(0, 0, 0, 255);
--	imlib_image_fill_polygon(poly);
--	imlib_polygon_free(poly);
- 
-+	for (int i= 0; i <= 3; i++) {
-+	  imlib_image_draw_line(x+i, y+3+i, x+i, y+9-i, 0);
-+	}
-+	  
- 	return;
- }
- 
\ No newline at end of file
diff --git a/pkgs/applications/graphics/feh/default.nix b/pkgs/applications/graphics/feh/default.nix
index 4f4a0cfce85c..e2304a27d0fa 100644
--- a/pkgs/applications/graphics/feh/default.nix
+++ b/pkgs/applications/graphics/feh/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, makeWrapper
+{ lib, stdenv, fetchFromGitHub, makeWrapper, fetchpatch
 , xorg, imlib2, libjpeg, libpng
 , curl, libexif, jpegexiforient, perl
 , enableAutoreload ? !stdenv.hostPlatform.isDarwin }:
@@ -16,7 +16,11 @@ stdenv.mkDerivation rec {
 
   patches = [
     # upstream PR: https://github.com/derf/feh/pull/723
-    ./0001-Right-click-crash-fix.patch
+    (fetchpatch {
+      name = "fix-right-click-buffer-overflow.patch";
+      url = "https://github.com/derf/feh/commit/2c31f8863b80030e772a529ade519fc2fee4a991.patch";
+      sha256 = "sha256-sUWS06qt1d1AyGfqKb+1BzZslYxOzur4q0ePEHcTz1g=";
+    })
   ];
 
   outputs = [ "out" "man" "doc" ]

@Artturin Artturin merged commit 6315a2a into NixOS:master Nov 20, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants