GNU bug report logs -
#11922
df doesn't handle \n in mount entries appropriately
Previous Next
Reported by: Pádraig Brady <P <at> draigBrady.com>
Date: Thu, 12 Jul 2012 11:57:01 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#11922: df doesn't handle \n in mount entries appropriately
which was filed against the coreutils package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 11922 <at> debbugs.gnu.org.
--
11922: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11922
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
On 07/13/2012 04:05 PM, Pádraig Brady wrote:
> On 07/13/2012 04:03 PM, Jim Meyering wrote:
>> Pádraig Brady wrote:
>>> On 07/12/2012 05:11 PM, Pádraig Brady wrote:
>
>>> * src/df.c (hide_problematic_chars): Replace '\n' with '\?'.
>>
>> Thanks. That looks fine, but shouldn't the '\?' above be just '?'
>
> oops thanks.
I adjusted a bit and now replace all control chars (< 0x20) with '?'.
They're easy to handle in all encodings and can only be problematic.
I added a test too.
I've pushed the attached, so I'm marking this done.
cheers,
Pádraig.
[df-newlines.diff (text/plain, attachment)]
[Message part 5 (message/rfc822, inline)]
The edge case where '\n' is in any of the /proc/mounts fields,
will cause problems with errant new lines being output by `df`.
(I notice `findmnt` from util-linux too has the same issue).
So df uses getmntent(3) to get the list, and from its man page we have:
"Since fields in the mtab and fstab files are separated by whitespace,
octal escapes are used to represent the four characters space (\040),
tab (\011), newline (\012) and backslash (\134) in those files when
they occur in one of the four strings in a mntent structure. The rou‐
tines addmntent() and getmntent() will convert from string representa‐
tion to escaped representation and back."
So how to handle this. I don't think it's appropriate to
reapply all the escaping in -P mode (which explicitly wants to avoid
multiline entries), since scripts might already be
handling the more common cases of <space> and <tab>.
So how about we just change \n -> \012.
This will at least improve the output for humans.
Scripts will not be able to directly use such entries,
but they couldn't anyway, and also processing of other
entries is no longer impacted.
Also `df` since coreutils 8.11 no longer wraps long lines,
preferring to expand alignment. This is easier to read
and avoids a common gotcha in scripts.
So even for non -P mode, we should do the \n -> \012 change.
It's tempting to do this transformation in read_file_system_list()
in gnulib, but that would cause that lib to output an ambiguous
format, and so it's probably best do the processing in each app
as required?
cheers,
Pádraig.
This bug report was last modified 12 years and 309 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.