Skip to content

absPath: Explicitly check if path is empty before accessing it - #9934

Merged
edolstra merged 1 commit into
NixOS:masterfrom
nmeum:absPath-out-of-bounds
Feb 5, 2024
Merged

edolstra merged 1 commit into
NixOS:masterfrom
nmeum:absPath-out-of-bounds

Conversation

@nmeum

@nmeum nmeum commented Feb 4, 2024 •

Copy link
Copy Markdown
Contributor

Motivation

This fixes UB in absPath, UB is bad.

Context

Within absPath, it is entirely possible for the path to be an empty string and many unit tests actually pass it as an empty string (e.g. both_roundrip or turnsEmptyPathIntoCWD). In this case, without this patch, absPath will perform a one-byte out-of-bounds access. This was discovered while enabling the nix test suite on Alpine where we compile all software with -D_GLIBCXX_ASSERTIONS=1, thus resulting in a test failure on Alpine.

Priorities and Process

Add 👍 to pull requests you find important.

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

It is entirely possible for the path to be an empty string and many
unit tests actually pass it as an empty string (e.g. both_roundrip or
turnsEmptyPathIntoCWD). In this case, without this patch, absPath will
perform a one-byte out-of-bounds access.

This was discovered while enabling the nix test suite on Alpine where
we compile all software with `-D_GLIBCXX_ASSERTIONS=1`, thus resulting
in a test failure on Alpine.
@nmeum
nmeum requested a review from edolstra as a code owner February 4, 2024 19:29
algitbot pushed a commit to alpinelinux/aports that referenced this pull request Feb 5, 2024
@edolstra
edolstra enabled auto-merge February 5, 2024 13:11
@edolstra
edolstra merged commit 6ec08b8 into NixOS:master Feb 5, 2024
algitbot pushed a commit to alpinelinux/aports that referenced this pull request Feb 5, 2024
This package is needed for the Nix test suite, it's really annoying
to package as upstream doesn't tag releases and, therefore, also
doesn't set an soname for the shared library.

However, running the Nix test suite in Alpine is beneficial as it
discovers bugs in Nix (see NixOS/nix#9934).

See also: emil-e/rapidcheck#255
@intelfx

intelfx commented Mar 7, 2024

Copy link
Copy Markdown
Contributor

@edolstra @thufschmitt @roberth can we please backport this to 2.20? Apologies for the mass ping, not sure who is the right person so I just looked at recent pulls' reviewers.

@thufschmitt

Copy link
Copy Markdown
Member

@edolstra @thufschmitt @roberth can we please backport this to 2.20? Apologies for the mass ping, not sure who is the right person so I just looked at recent pulls' reviewers.

Yes!
Thanks for the ping. I've asked the bot to open the backport PR, should arrive soon

tebowy pushed a commit to tebowy/nix that referenced this pull request Jul 11, 2024
absPath: Explicitly check if path is empty before accessing it
(cherry picked from commit 6ec08b8)
Change-Id: Ieeb53fb65d0e334e6017ceb3a48b3b6ae1047843
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants