Bug 209039 - getextattr(8) -x garbles non-ASCII bytes
Summary: getextattr(8) -x garbles non-ASCII bytes
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-25 16:52 UTC by Alan Somers
Modified: 2016-05-04 21:23 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2016-04-25 16:52:46 UTC
getextattr is used to print the value of an extended attribute on a file.  The -x option prints the output in hex instead of ASCII.  It prints one byte at a time, with spaces between bytes.  However, when printing bytes with the high bit set, getextattr erroneously interprets the single byte as a signed 32-bit number.

$ getextattr user umlauts foofoo     aeiou äëïöü
$ getextattr -x user umlauts foofoo     61 65 69 6f 75 20 ffffffc3 ffffffa4 ffffffc3 ffffffab ffffffc3 ffffffaf ffffffc3 ffffffb6 ffffffc3 ffffffbc
Comment 1 commit-hook freebsd_committer freebsd_triage 2016-05-04 21:08:02 UTC
A commit references this bug:

Author: asomers
Date: Wed May  4 21:07:30 UTC 2016
New revision: 299087
URL: https://svnweb.freebsd.org/changeset/base/299087

Log:
  Fix "getextattr -x" with non-ascii attribute values

  extattr/rmextattr.c
  	When printing hex output, treat all attribute values as unsigned
  	char arrays instead of sign extending them to 32 bit values.

  extattr/tests/extattr_test.sh
  	Add a regression test

  PR:		209039
  MFC after:	4 weeks
  Sponsored by:	Spectra Logic Corp

Changes:
  head/usr.sbin/extattr/rmextattr.c
  head/usr.sbin/extattr/tests/extattr_test.sh