]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9068 fix backslash escaping
authorHoward Chu <hyc@openldap.org>
Mon, 26 Aug 2019 16:51:53 +0000 (17:51 +0100)
committerHoward Chu <hyc@openldap.org>
Mon, 26 Aug 2019 16:55:23 +0000 (17:55 +0100)
mdb_load wasn't properly inserting escaped backslashes into the data.
mdb_dump wasn't escaping backslashes when generating printable output.

libraries/liblmdb/mdb_dump.c
libraries/liblmdb/mdb_load.c

index 9df5dc0b161f3baaf663416f59da474d3abc443e..27c4c19f54e5bd745477462159ab3060e6ae4512 100644 (file)
@@ -68,6 +68,8 @@ static void text(MDB_val *v)
        end = c + v->mv_size;
        while (c < end) {
                if (isprint(*c)) {
+                       if (*c == '\\')
+                               putchar('\\');
                        putchar(*c);
                } else {
                        putchar('\\');
index 0f177f1ec2d6754a13f5ba192847ded33cb94475..73ffad0555e663fb5dd63b95ccac3a117b91bf5f 100644 (file)
@@ -238,7 +238,7 @@ badend:
                while (c2 < end) {
                        if (*c2 == '\\') {
                                if (c2[1] == '\\') {
-                                       c1++; c2 += 2;
+                                       *c1++ = *c2;
                                } else {
                                        if (c2+3 > end || !isxdigit(c2[1]) || !isxdigit(c2[2])) {
                                                Eof = 1;
@@ -246,8 +246,8 @@ badend:
                                                return EOF;
                                        }
                                        *c1++ = unhex(++c2);
-                                       c2 += 2;
                                }
+                               c2 += 2;
                        } else {
                                /* copies are redundant when no escapes were used */
                                *c1++ = *c2++;