Page MenuHomeFreeBSD

Don't let ATF call basename() and dirname() in a non-standard way.
ClosedPublic

Authored by ed on May 29 2016, 10:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 12, 2:04 PM
Unknown Object (File)
Thu, Apr 11, 7:55 PM
Unknown Object (File)
Wed, Apr 10, 12:55 AM
Unknown Object (File)
Sun, Apr 7, 11:30 AM
Unknown Object (File)
Jan 30 2024, 11:44 AM
Unknown Object (File)
Jan 21 2024, 9:37 PM
Unknown Object (File)
Dec 13 2023, 11:10 AM
Unknown Object (File)
Nov 29 2023, 5:31 PM
Subscribers

Details

Summary

POSIX basename() and dirname() are allowed to overwrite the input
buffer. The advantage of implementing it that way is that the functions
can be thread-safe, as they don't store the result in a global buffer.

It looks like ATF wants to call basename() and dirname() in the
non-standard way where the argument is of type "const char *". This
change disables the calls to basename() and dirname(), which only seems
to affect the formatting of some rare debug/error messages.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ed retitled this revision from to Don't let ATF call basename() and dirname() in a non-standard way..
ed updated this object.
ed edited the test plan for this revision. (Show Details)
ed added reviewers: ngie, jmmv.
ngie edited edge metadata.

The change looks good to me.

It's testing invariants in atf-c(3) when NDEBUG isn't defined (which seems backwards to be honest...), to make sure that basename(3)/dirname(3) are functioning as expected, so the net effect of the proposed change is ok.

This revision is now accepted and ready to land.Jun 8 2016, 12:43 PM
This revision was automatically updated to reflect the committed changes.

ngie is right in that basename and dirname are used for sanity-checking purposes. Why this is in the live code path and not in tests... doesn't make much sense, and I guess this could all be dropped.

But ngie, why do you say that this is being tested when NDEBUG is set? The check is gated by the INV macro, which is only defined in the !NDEBUG case.