mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
Handle octal escapes in /proc/self/mountinfo
This commit is contained in:
parent
f406288cc7
commit
e666e1156f
3 changed files with 24 additions and 2 deletions
|
@ -1101,6 +1101,21 @@ bool endOfList(std::istream & str)
|
|||
}
|
||||
|
||||
|
||||
string decodeOctalEscaped(const string & s)
|
||||
{
|
||||
string r;
|
||||
for (string::const_iterator i = s.begin(); i != s.end(); ) {
|
||||
if (*i != '\\') { r += *i++; continue; }
|
||||
unsigned char c = 0;
|
||||
++i;
|
||||
while (i != s.end() && *i >= '0' && *i < '8')
|
||||
c = c * 8 + (*i++ - '0');
|
||||
r += c;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
void ignoreException()
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -332,6 +332,12 @@ string parseString(std::istream & str);
|
|||
bool endOfList(std::istream & str);
|
||||
|
||||
|
||||
/* Escape a string that contains octal-encoded escape codes such as
|
||||
used in /etc/fstab and /proc/mounts (e.g. "foo\040bar" decodes to
|
||||
"foo bar"). */
|
||||
string decodeOctalEscaped(const string & s);
|
||||
|
||||
|
||||
/* Exception handling in destructors: print an error message, then
|
||||
ignore the exception. */
|
||||
void ignoreException();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue