Page MenuHomeFreeBSD

Replace makefs' hand-rolled unescaping with strunvis.
ClosedPublic

Authored by benno on Aug 22 2017, 10:21 PM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

benno created this revision.Aug 22 2017, 10:21 PM
emaste added a subscriber: emaste.Aug 23 2017, 4:52 PM
marcel edited edge metadata.Aug 23 2017, 7:01 PM

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...

benno updated this revision to Diff 32347.Aug 23 2017, 8:37 PM
  • Remove left-over line from debugging.
  • Simplify strnunvis call in read_mtree_spec.
benno marked 2 inline comments as done.Aug 23 2017, 8:38 PM
marcel accepted this revision.Aug 23 2017, 9:18 PM

LGTM...

This revision is now accepted and ready to land.Aug 23 2017, 9:18 PM
benno added a reviewer: gjb.Aug 23 2017, 9:26 PM
This revision was automatically updated to reflect the committed changes.