summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2012-08-13 16:25:01 +0200
committerKarel Zak2012-08-13 16:35:03 +0200
commit096db1ead1ee2baea4acf5e44b192ad442733023 (patch)
tree1f4f8193b0f72dd7d948c90a024b564d4f726b2e /lib
parentdmesg: fix kmsg read if read returns EPIPE (diff)
downloadkernel-qcow2-util-linux-096db1ead1ee2baea4acf5e44b192ad442733023.tar.gz
kernel-qcow2-util-linux-096db1ead1ee2baea4acf5e44b192ad442733023.tar.xz
kernel-qcow2-util-linux-096db1ead1ee2baea4acf5e44b192ad442733023.zip
libmount: fix unmangle code
old version: /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\134 fixed version: /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\ Reported-by: Naja Melan <najamelan@autistici.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/mangle.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/mangle.c b/lib/mangle.c
index faddeb879..2b1817361 100644
--- a/lib/mangle.c
+++ b/lib/mangle.c
@@ -51,12 +51,13 @@ char *mangle(const char *s)
void unmangle_to_buffer(const char *s, char *buf, size_t len)
{
size_t sz = 0;
+ char *x = buf;
if (!s)
return;
while(*s && sz < len - 1) {
- if (*s == '\\' && sz + 4 < len - 1 && isoctal(s[1]) &&
+ if (*s == '\\' && sz + 3 < len - 1 && isoctal(s[1]) &&
isoctal(s[2]) && isoctal(s[3])) {
*buf++ = 64*(s[1] & 7) + 8*(s[2] & 7) + (s[3] & 7);
@@ -78,7 +79,7 @@ void unhexmangle_to_buffer(const char *s, char *buf, size_t len)
return;
while(*s && sz < len - 1) {
- if (*s == '\\' && sz + 4 < len - 1 && s[1] == 'x' &&
+ if (*s == '\\' && sz + 3 < len - 1 && s[1] == 'x' &&
isxdigit(s[2]) && isxdigit(s[3])) {
*buf++ = from_hex(s[2]) << 4 | from_hex(s[3]);