Bug 261307 - [patch] net/gitup: Bus error
Summary: [patch] net/gitup: Bus error
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Nuno Teixeira
URL:
Keywords: easy, patch-ready
Depends on:
Blocks:
 
Reported: 2022-01-18 14:13 UTC by Eugene Grosbein
Modified: 2022-05-16 10:29 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (eduardo)


Attachments
fix SIGBUS (988 bytes, patch)
2022-01-18 14:13 UTC, Eugene Grosbein
no flags Details | Diff
fix SIGBUS (990 bytes, patch)
2022-01-21 20:04 UTC, Eugene Grosbein
no flags Details | Diff
fix SIGBUS (990 bytes, patch)
2022-02-07 13:39 UTC, Eugene Grosbein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein freebsd_committer freebsd_triage 2022-01-18 14:13:49 UTC
Created attachment 231129 [details]
fix SIGBUS

This commit changed contrib/bc/configure from regular file to the symlink to configure.sh

https://cgit.freebsd.org/src/commit/contrib/bc/configure?h=stable/12&id=e32b8140f4e7de93eb7d571e7fcb2bf9db6c97a3

gitup-0.96 crashes with SIGBUS trying to repair or update local repository copy when old (pre-commit) tree is present:

1) The function save_repairs() contains logic error calling calculate_file_hash() function to calculate hash of local file passing file mode of an object from the repository. The function calculate_file_hash() assumes that mode describes local file, calls readlink() for supposed symlink, but readlink() returns -1 with errno=EINVAL. This returned value ("uint32_t bytes_read" assigned with -1) is used in a statement:

temp_path[bytes_read] = '\0';

SIGBUS is imminent.

2) With this bug fixed by passing real mode of local file to calculate_file_hash(), the function save_file() still does not handle the situation because it halts on any error on symlink creation including EEXIST. Instead, it should remove old file preventing symlink creation and retry.

The patch solving the problem is attached.
Comment 1 Eugene Grosbein freebsd_committer freebsd_triage 2022-01-21 20:04:29 UTC
Created attachment 231226 [details]
fix SIGBUS

Update the patch to add missing parenthesis.
Comment 2 Nuno Teixeira freebsd_committer freebsd_triage 2022-01-22 11:42:04 UTC
Hello,

Could you please open an issue at https://github.com/johnmehr/gitup about this change/fix and refer this PR so author can test and analise it?

Thanks,

Nuno Teixeira
Comment 3 Eugene Grosbein freebsd_committer freebsd_triage 2022-02-07 13:39:30 UTC
Created attachment 231608 [details]
fix SIGBUS

Add parenthesis to correct logic error in previous patch.
Comment 4 Eugene Grosbein freebsd_committer freebsd_triage 2022-02-07 13:42:21 UTC
(In reply to Nuno Teixeira from comment #2)

I have some problems communicating with Github at the moment.
Comment 5 Nuno Teixeira freebsd_committer freebsd_triage 2022-03-21 13:34:08 UTC
hello Eugene,

I have openned an issue at githup: https://github.com/johnmehr/gitup/issues/79

Cheers
Comment 6 Nuno Teixeira freebsd_committer freebsd_triage 2022-03-24 15:05:25 UTC
Hello Eugene,

Your patch was applied to current source by Mehr.

Closed #79 ( https://github.com/johnmehr/gitup/issues/79 )

Please test it fetching lateast source.

I will close this PR for now.

Thanks,

Nuno Teixeira
Comment 7 Eugene Grosbein freebsd_committer freebsd_triage 2022-03-25 04:10:05 UTC
Our port still has not a fix. Will you add the patch to the port until next gitup release? Or I can add it myself, if you wish.
Comment 8 commit-hook freebsd_committer freebsd_triage 2022-04-29 02:16:32 UTC
A commit in branch main references this bug:

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 (new) | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
Comment 9 Nuno Teixeira freebsd_committer freebsd_triage 2022-05-16 10:29:55 UTC
(In reply to Eugene Grosbein from comment #7)

Hello Eugene,

Thank you for appying the patch, I was waiting for a new release that already includes it.

Thank you, and sorry for my delay.

Cheers,

Nuno Teixeira