Sam Price commented: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1444#note_157873 ### Provenance and upstream divergence (for reviewers) **Where this file came from.** RTEMS imported `realpath()` from FreeBSD in commit `ea9232d016` ("Add realpath call.", 2014-10-24). The source it copied is recorded in the file's `__FBSDID`: FreeBSD `release/9.1.0` rev **240647**, 2012-09-18. It is not a pristine copy — it already carries local `#ifdef __rtems__` adjustments from `31103bd0b3` (the `-Wsign-compare` cleanup), which this MR leaves untouched. **What this MR takes.** The two upstream bug fixes to the symlink path, verbatim in intent and adapted to the 2012 structure: - empty symlink (`readlink` returns 0) → `ENOENT`, before the old `symlink[slen - 1]` read went one byte before the buffer; - over-long target (`slen >= sizeof(symlink)`) → `ENAMETOOLONG`, instead of silently truncating and then following the shortened path. The `readlink()` size argument also goes from `sizeof(symlink) - 1` back to `sizeof(symlink)`, matching upstream, so the `>=` overflow check is exact. **What has changed upstream since 2012 that this MR does _not_ take.** Current FreeBSD has refactored the whole file: the body is split into a `realpath1()` helper with a thin `realpath()` wrapper, and the malloc bookkeeping moved out of the inner loop (the wrapper frees `m` on failure) — so upstream no longer has the `if (m) free(resolved)` idiom this file still uses on every error path. Pulling that refactor is a much larger, structural change and is intentionally left as a separate future MR; this one is kept to the minimal, reviewable bug fix. **Test.** The empty-symlink case is upstream's `realpath_empty_symlink` (`lib/libc/tests/gen/realpath2_test.c`) rewritten for this suite (RTEMS imports no ATF tests). The over-long case is new here — upstream has the fix but no test for it. Upstream's other four cases (`realpath_null`, `realpath_empty`, `realpath_buffer_overflow`, `realpath_partial`) are not about symlinks and are not brought into an fssymlink test. -- View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1444#note_157873 You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/sent_notifications/5-byjfaumtk6sm2s182k674b4qb-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help
_______________________________________________ bugs mailing list [email protected] http://lists.rtems.org/mailman/listinfo/bugs
