git: cc3322db8bfb - main - net/gitup: fix SIGBUS

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Fri, 29 Apr 2022 02:16:03 UTC
The branch main has been updated by eugen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cc3322db8bfb8393736ec23624a36ccacb7e22b7

commit cc3322db8bfb8393736ec23624a36ccacb7e22b7
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2022-04-29 02:12:22 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2022-04-29 02:12:22 +0000

    net/gitup: fix SIGBUS
    
    Temporary add the patch fixing SIGBUS.
    The patch already accepted to upstream repo but next release
    delayed for long time.
    
    Many thanks to eduardo@ for submitting the patch upstream.
    
    PR:             261307
    Approved by:    eduardo (maintainer timeout, 1 month)
---
 net/gitup/Makefile            |  1 +
 net/gitup/files/patch-gitup.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/net/gitup/Makefile b/net/gitup/Makefile
index 8b1fe7efa168..38480a43ecc5 100644
--- a/net/gitup/Makefile
+++ b/net/gitup/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	gitup
 DISTVERSION=	0.96
+PORTREVISION=	1
 CATEGORIES=	net
 
 MAINTAINER=	eduardo@FreeBSD.org
diff --git a/net/gitup/files/patch-gitup.c b/net/gitup/files/patch-gitup.c
new file mode 100644
index 000000000000..06765095ef7d
--- /dev/null
+++ b/net/gitup/files/patch-gitup.c
@@ -0,0 +1,32 @@
+--- gitup.c.orig	2021-09-05 19:58:01.000000000 +0300
++++ gitup.c	2022-01-18 16:53:41.999972000 +0300
+@@ -676,7 +676,8 @@ save_file(char *path, int mode, char *buffer, int buff
+ 		memcpy(temp_buffer, buffer, buffer_size);
+ 		temp_buffer[buffer_size] = '\0';
+ 
+-		if (symlink(temp_buffer, path) == -1)
++		if (symlink(temp_buffer, path) == -1 &&
++		    (unlink(path), symlink(temp_buffer, path)) == -1)
+ 			err(EXIT_FAILURE,
+ 				"save_file: symlink failure %s -> %s",
+ 				path,
+@@ -2800,7 +2801,9 @@ save_repairs(connector *session)
+ 					"save_repairs: cannot create %s",
+ 					found_file->path);
+ 		} else {
+-			missing = !path_exists(found_file->path);
++			struct stat st;
++
++			missing = stat(found_file->path, &st) != 0;
+ 			update  = true;
+ 
+ 			/*
+@@ -2813,7 +2816,7 @@ save_repairs(connector *session)
+ 
+ 				check_hash = calculate_file_hash(
+ 					found_file->path,
+-					found_file->mode);
++					st.st_mode);
+ 
+ 				buffer_hash = calculate_object_hash(
+ 					found_object->buffer,