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)
Wed, Dec 25, 8:03 AM
Unknown Object (File)
Fri, Dec 20, 7:47 PM
Unknown Object (File)
Oct 3 2024, 12:29 PM
Unknown Object (File)
Oct 2 2024, 8:49 PM
Unknown Object (File)
Oct 2 2024, 6:39 AM
Unknown Object (File)
Sep 30 2024, 2:24 AM
Unknown Object (File)
Sep 25 2024, 9:35 PM
Unknown Object (File)
Sep 24 2024, 9:14 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.