]> 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:51:53 +0000 (17:51 +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 b7737f12de16e9d1e8edd068ad1518cc7522633d..068dab5a8ed825ce70fcfa4aa3c19e0ff62e22b4 100644 (file)
@@ -64,6 +64,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 ad911c088cf1346faecbca920b88e180f9f48a3b..e900ae660fa39be1a972d0d847a3ed86a7b8ee15 100644 (file)
@@ -236,7 +236,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;
@@ -244,8 +244,8 @@ badend:
                                                return EOF;
                                        }
                                        *c1++ = unhex(++c2);
-                                       c2 += 2;
                                }
+                               c2 += 2;
                        } else {
                                /* copies are redundant when no escapes were used */
                                *c1++ = *c2++;