Page MenuHomeFreeBSD

Replace makefs' hand-rolled unescaping with strunvis.
ClosedPublic

Authored by benno on Aug 22 2017, 10:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 12:21 AM
Unknown Object (File)
Sep 10 2023, 4:56 AM
Unknown Object (File)
Sep 5 2023, 12:40 PM
Unknown Object (File)
Sep 5 2023, 12:29 PM
Unknown Object (File)
Sep 5 2023, 12:29 PM
Unknown Object (File)
Sep 5 2023, 12:27 PM
Unknown Object (File)
Aug 31 2023, 11:32 AM
Unknown Object (File)
Jul 20 2023, 2:40 AM
Subscribers

Details

Summary

mtree path names and link attributes are encoded, generally using strvis. Newer
versions of mtree will use C-style escapes but previously the accepted form was
octal escapes. makefs' mtree code spots the C-style escapes but fails to deal
with octal escapes correctly.

Remove mtree's escape-decoding code (except for a few instances where it's
needed) and instead pass pathnames and link targets through strunvis prior to
use.

Diff Detail

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

Event Timeline

Two comments:

  1. I see that there's an unvis(3) function as well. That seems like a good way to handle escape sequences in read_word() and not have callers of read_word() handle escape characters.
  2. makefs needs to be portable. Do you know if vis(3) exists on macOS and Linux?
usr.sbin/makefs/mtree.c
570 โ†—(On Diff #32328)

Stray assignment?
This is a dereference of node->symlink before checking for a NULL pointer...

965 โ†—(On Diff #32328)

Maybe just write:

if (strnunvis(pathspec, PATH_MAX, pathtmp) == -1) {
    error = errno;
    goto out;
}

That avoids having to reset error and avoids confusion about the return value of strnunvis: it's not an error...

  • Remove left-over line from debugging.
  • Simplify strnunvis call in read_mtree_spec.
This revision is now accepted and ready to land.Aug 23 2017, 9:18 PM
This revision was automatically updated to reflect the committed changes.