r7725: fixed a bug with partial asn1 frames in the ldap client
[kai/samba.git] / source / libcli / ldap / ldap_client.c
index f2b09e89e326c7a42aa53a998767c93af2c2f130..41764b9a374d9f0fb8171a9675557f558f8a28f2 100644 (file)
@@ -156,6 +156,8 @@ static void ldap_try_decode_plain(struct ldap_connection *conn)
        /* try and decode - this will fail if we don't have a full packet yet */
        while (asn1.ofs < asn1.length) {
                struct ldap_message *msg = talloc(conn, struct ldap_message);
+               off_t saved_ofs = asn1.ofs;
+                       
                if (msg == NULL) {
                        ldap_connection_dead(conn);
                        return;
@@ -164,6 +166,7 @@ static void ldap_try_decode_plain(struct ldap_connection *conn)
                if (ldap_decode(&asn1, msg)) {
                        ldap_match_message(conn, msg);
                } else {
+                       asn1.ofs = saved_ofs;
                        talloc_free(msg);
                        break;
                }