Skip to content

cmake: bring back hidden visibility for the static build#7288

Merged
ethomson merged 1 commit into
libgit2:mainfrom
carlosmn:cmn/bring-back-hidden
Jun 25, 2026
Merged

cmake: bring back hidden visibility for the static build#7288
ethomson merged 1 commit into
libgit2:mainfrom
carlosmn:cmn/bring-back-hidden

Conversation

@carlosmn

Copy link
Copy Markdown
Member

We've had -fvisibility=hidden from the beginning of the project, and the code setting it has gone through multiple iterations.

In b41e24a (2013-01-10; Add -fPIC only if BUILD_SHARED_LIBS is ON) as part of building for Amiga, this option was changed to bet set only for shared builds, erroneously believing that this visibility would not affect static builds.

Not so. The recent introduction of llhttp has made some users of the static library end up exporting the symbols for that library which conflict with this library being used via other means in the same program.

Bring back the logic of not enabling -fvisibility=hidden for MINGW to avoid it complaining which was the reason why it was grouped with -fPIC in the first place.

As pointed out by libgit2/rugged#1000

The PR that introduced this change was #1218 and this did come up but it was convincing enough that we figured it wouldn't affect static builds.

Comment thread cmake/DefaultCFlags.cmake Outdated
We've had `-fvisibility=hidden` from the beginning of the project, and the code
setting it has gone through multiple iterations.

In b41e24a (2013-01-10; Add -fPIC only if BUILD_SHARED_LIBS is ON) as part of
building for Amiga, this option was changed to bet set only for shared builds,
erroneously believing that this visibility would not affect static builds.

Not so. The recent introduction of llhttp has made some users of the static
library end up exporting the symbols for that library which conflict with this
library being used via other means in the same program.

Bring back the logic of not enabling `-fvisibility=hidden` for MINGW to avoid it
complaining which was the reason why it was grouped with `-fPIC` in the first place.
@carlosmn
carlosmn force-pushed the cmn/bring-back-hidden branch from 714f572 to d5af509 Compare June 16, 2026 21:00
@carlosmn
carlosmn requested a review from ethomson June 16, 2026 21:02
@carlosmn

Copy link
Copy Markdown
Member Author

It looks like the tests against bitbucket are failing because the test repo is gone.

@ethomson
ethomson merged commit 32b564e into libgit2:main Jun 25, 2026
21 of 40 checks passed
@ethomson

Copy link
Copy Markdown
Member

Thanks! I'll try to figure out bitbucket. 🥴

@carlosmn
carlosmn deleted the cmn/bring-back-hidden branch June 26, 2026 07:27
@brodock

brodock commented Jul 1, 2026

Copy link
Copy Markdown

@ethomson any chance this can be include in a 1.9.5 alongside with new rugged release? (to address libgit2/rugged#1000)

@ethomson

Copy link
Copy Markdown
Member

@brodock this is available in v1.9.6

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jul 19, 2026
v1.9.6

This release includes a few small but important bugfixes.

* load_known_hosts: do not fail if homedir is invalid
  by @JonasVautherin in libgit2/libgit2#7056
* Fix segfault on Android when no HOME set by @501st-alpha1 in
  libgit2/libgit2#7309
* cmake: bring back hidden visibility for the static build by
  @carlosmn in libgit2/libgit2#7288


v1.9.5

This is a security release with multiple changes.

* Fix for blame error handling on hunk creation failures

  `hunk_from_entry` can return `NULL` on error; handle that and
  return an error.

* Fix for potential PCRE memory access: 1-byte heap-buffer-overflow
  WRITE in bundled PCRE 8.45 reachable via revspec

  `git_revparse_single` accepts revspecs of the form `:/<pattern>`
  (the "grep by commit message" shorthand) and forwards `<pattern>`
  directly to libgit2's regex backend. When libgit2 is using its builtin
  regular expression engine, this causes a heap buffer overflow.

* Fix for CVE-2026-53586: give auth callback current host

  libgit2's builtin HTTP transport follows offsite redirects for the
  initial smart HTTP request by default. If the redirected server then
  returns 401 Unauthorized, libgit2 asks the application credential
  callback for credentials using the original remote URL, not the
  redirected URL. The returned credential is then attached to the next
  request to the redirected host as an Authorization header.

* Fix for CVE-2026-53587: libgit2 version 1.9.4 and below is vulnerable
  to a heap out-of-bounds read in `set_data` in
  `src/libgit2/transports/smart_pkt.c`.

  When given capabilities, we check for the object-format capability; we
  need to ensure that the current packet buffer is large enough before
  actually doing the check.

* Fix for CVE-2026-53585: Unbounded Memory Allocation via Delta
  Object Result-Size Header

  Potential denial of service because `git_delta_apply` reads the
  claimed result size (`res_sz`) from the delta object header — data
  entirely controlled by the sender — and immediately allocates a
  buffer of that size.

* Fix for CVE-2026-53584: submodule: check paths for escaping

  A crafted repository with a submodule whose path contains traversal
  components (e.g. "../") can cause the library to create directories
  outside the repository's working tree.

* Fix for CVE-2026-53583: inverted IP SubjectAltName comparison in
  OpenSSL backend.

  An inverted comparison in the OpenSSL TLS backend causes IP
  SubjectAltName (SAN) verification to accept certificates with
  mismatched IP addresses and reject certificates with correct IP
  addresses. This allows a network attacker with a valid CA-signed
  certificate containing any IP SAN to perform MITM attacks against
  libgit2 clients connecting to IP-literal HTTPS URLs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants