libpkgconf: path: supply buffer to realpath #208

Merged
grobian merged 1 commits from master into master 2021-01-08 23:44:41 +00:00
grobian commented 2021-01-08 10:04:15 +00:00 (Migrated from github.com)

To avoid a crash on some platforms (like Darwin 9) provide a buffer to
realpath(3).

Darwin 9 (last PPC target) documents realpath needs to be given a buffer
to the resolved_path argument large enough to hold PATH_MAX bytes.
With NULL argument it crashes. Solaris makes no mention of
resolved_path to be allowed NULL, yet recent versions accept it and
malloc(3) accordingly.

Because the documentation explicitly mentions PATH_MAX being the limit
to what realpath(3) would write in resolved_path, switching to a static
buffer here doesn't limit resolution compared to dynamically allocating
a buffer by realpath(3).

While this change requires a bit more space on the stack, it avoids a
malloc/free sequence, and allows successful operation on (older)
platforms that lack support for dynamically allocating a return buffer
in realpath(3).

Signed-off-by: Fabian Groffen grobian@gentoo.org

To avoid a crash on some platforms (like Darwin 9) provide a buffer to realpath(3). Darwin 9 (last PPC target) documents realpath needs to be given a buffer to the resolved_path argument large enough to hold PATH_MAX bytes. With NULL argument it crashes. Solaris makes no mention of resolved_path to be allowed NULL, yet recent versions accept it and malloc(3) accordingly. Because the documentation explicitly mentions PATH_MAX being the limit to what realpath(3) would write in resolved_path, switching to a static buffer here doesn't limit resolution compared to dynamically allocating a buffer by realpath(3). While this change requires a bit more space on the stack, it avoids a malloc/free sequence, and allows successful operation on (older) platforms that lack support for dynamically allocating a return buffer in realpath(3). Signed-off-by: Fabian Groffen <grobian@gentoo.org>

Note to self: change this PATH_MAX to our internal equivalent for HURD.

Note to self: change this PATH_MAX to our internal equivalent for HURD.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ariadne/pkgconf#208
There is no content yet.