Skip to content

libexpr: fix various overflows and type mismatches (backport #13309) #13614

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

Open
wants to merge 1 commit into
base: 2.29-maintenance
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 30, 2025

Motivation

I found wrong casts of NixInt values, which can cause crashes of current Nix versions because of sizeof(unsigned int) < sizeof(NixInt::Inner), e.g.

nix-repl> builtins.substring 4294967296 5 "hello"  
error: basic_string_view::substr: __pos (which is 4294967296) > __size (which is 5)

Furthermore usually sizeof(unsigned int) < sizeof(size_t) on 64 bit systems, which becomes problematic when a list contains more than 2^32 values and this case isn't impossible. Thus size_t is used as index type.

Context

Includes tests for cases, where NixInt::Inner was incorrectly casted.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.


This is an automatic backport of pull request #13309 done by [Mergify](https://mergify.com).

(cherry picked from commit afd9c78)

# Conflicts:
#	src/libexpr-tests/primops.cc
#	src/libexpr/primops.cc
@mergify mergify bot added automatic backport This PR is a backport produced by automation (does not trigger backporting) conflicts labels Jul 30, 2025
@mergify mergify bot requested a review from roberth as a code owner July 30, 2025 12:37
@mergify mergify bot added the merge-queue label Jul 30, 2025
@mergify mergify bot requested a review from edolstra as a code owner July 30, 2025 12:37
Copy link
Contributor Author

mergify bot commented Jul 30, 2025

Cherry-pick of afd9c78 has failed:

On branch mergify/bp/2.29-maintenance/pr-13309
Your branch is up to date with 'origin/2.29-maintenance'.

You are currently cherry-picking commit afd9c7850.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/libexpr-tests/primops.cc
	both modified:   src/libexpr/primops.cc

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automatic backport This PR is a backport produced by automation (does not trigger backporting) conflicts merge-queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant