Skip to content

Commit

Permalink
w3m: fix fdsan error when run on android 11
Browse files Browse the repository at this point in the history
The file descriptor sanitizer keeps track of opened file descriptors
and kills programs that closes fds multiple times, or fails to close
fds.  In w3m's case a fd for a tty was obtained and saved in the ttyf
variable, but when the tty was later closed is was done using the tty
variable and not the obtained ttyf.  To my current understanding this
can lead to undesired behaviour when using multiple threads, as
another thread might write to or read from ttyf after it has been
closed.

Error looks like
fdsan: attempted to close file descriptor 3, expected to be unowned, actually owned by FILE* 0xb6c8800c

This commit fixes [1]. See also fdsan docs [2] and issue opened in the
android bug tracker [3].

[1] #6410
[2] https://android.googlesource.com/platform/bionic/+/master/docs/fdsan.md
[3] https://issuetracker.google.com/issues/184380442
  • Loading branch information
Grimler91 committed Apr 5, 2021
1 parent 16b0fab commit fee1315
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/w3m/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TERMUX_PKG_MAINTAINER="@termux"
_MAJOR_VERSION=0.5.3
_MINOR_VERSION=20190105
TERMUX_PKG_VERSION=${_MAJOR_VERSION}.${_MINOR_VERSION}
TERMUX_PKG_REVISION=5
TERMUX_PKG_REVISION=6
# The upstream w3m project is dead, but every linux distribution uses
# this maintained fork in debian:
TERMUX_PKG_SRCURL=https://github.com/tats/w3m/archive/v${_MAJOR_VERSION}+git${_MINOR_VERSION}.tar.gz
Expand Down
11 changes: 11 additions & 0 deletions packages/w3m/fdsan-fd-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- ./terms.c.orig 2021-04-05 12:45:45.535462776 +0000
+++ ./terms.c 2021-04-05 12:45:55.075444134 +0000
@@ -871,7 +871,7 @@
close_tty(void)
{
if (tty > 2)
- close(tty);
+ fclose(ttyf);
}

char *

0 comments on commit fee1315

Please sign in to comment.