[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] mntent_r.c: encode/decode fixes
From: |
Alexander Achenbach |
Subject: |
[PATCH] mntent_r.c: encode/decode fixes |
Date: |
Sat, 25 Oct 2003 20:16:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021205 Debian/1.2.1-0 |
Hi all.
All CVS revisions of 'libc/misc/mntent_r.c' up to and including 1.17
incorrectly encode/decode fstab and mtab entries containing mount
points with tabs or newlines.
While such cases of mount points are rather exotic, they are not
totally impossible, and the existing code claims to handle at least
tab characters (in addition to space and backslash) correctly.
However, it forgets about encoding newlines and encodes tabs as
newlines instead.
The attached patch of 'libc/misc/mntent_r.c' tries to fix this,
making it somewhat more compatible (though not identical) to the
encoding/decoding behaviour of the 'mount' command of 'util-linux'.
[ I'm sending this report into the blue, as I'm currently unable
to connect to GNATS via any of the links on
http://www.gnu.org/software/libc/ . ]
Best regards
Alexander Achenbach
--- mntent_r.c.orig Sat Oct 25 19:45:49 2003
+++ mntent_r.c Sat Oct 25 19:48:58 2003
@@ -84,12 +84,18 @@
*wp++ = ' ';
rp += 3;
}
- else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '2')
+ else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '1')
{
- /* \012 is a TAB. */
+ /* \011 is a TAB. */
*wp++ = '\t';
rp += 3;
}
+ else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '2')
+ {
+ /* \012 is a NEWLINE. */
+ *wp++ = '\n';
+ rp += 3;
+ }
else if (rp[0] == '\\' && rp[1] == '\\')
{
/* We have to escape \\ to be able to represent all characters. */
@@ -181,7 +187,7 @@
const char *rp = name; \
\
while (*rp != '\0')
\
- if (*rp == ' ' || *rp == '\t' || *rp == '\\') \
+ if (*rp == ' ' || *rp == '\t' || *rp == '\n' || *rp == '\\') \
break; \
else \
++rp; \
@@ -189,7 +195,7 @@
if (*rp != '\0') \
{
\
/* In the worst case the length of the string can increase to \
- founr times the current length. */ \
+ four times the current length. */ \
char *wp; \
\
rp = name; \
@@ -204,6 +210,13 @@
*wp++ = '0'; \
} \
else if (*rp == '\t') \
+ { \
+ *wp++ = '\\'; \
+ *wp++ = '0'; \
+ *wp++ = '1'; \
+ *wp++ = '1'; \
+ } \
+ else if (*rp == '\n') \
{ \
*wp++ = '\\'; \
*wp++ = '0'; \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] mntent_r.c: encode/decode fixes,
Alexander Achenbach <=