]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Simplify abandon processing
authorOndřej Kuzník <ondra@mistotebe.net>
Fri, 23 Jun 2017 09:58:46 +0000 (10:58 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:55:46 +0000 (17:55 +0000)
servers/lloadd/operation.c

index feb40c1a6806b14905fec3a30126e1c900970fe6..6bb0836af6affba5aac46185540b097895c11f26 100644 (file)
@@ -543,21 +543,17 @@ request_abandon( Connection *c, Operation *op )
     Operation *request, needle = { .o_client_connid = c->c_connid };
     int rc = LDAP_SUCCESS;
 
-    /* parse two's complement integer */
-    if ( !BER_BVISEMPTY( &op->o_request ) ) {
-        unsigned char *buf = (unsigned char *)op->o_request.bv_val;
-        ber_len_t i;
-        ber_int_t netnum = buf[0] & 0xff;
-
-        /* sign extend */
-        netnum = ( netnum ^ 0x80 ) - 0x80;
-
-        /* shift in the bytes */
-        for ( i = 1; i < op->o_request.bv_len; i++ ) {
-            netnum = ( netnum << 8 ) | buf[i];
-        }
+    if ( ber_decode_int( &op->o_request, &needle.o_client_msgid ) ) {
+        Debug( LDAP_DEBUG_STATS, "request_abandon: "
+                "connid=%lu msgid=%d invalid integer sent in abandon request\n",
+                c->c_connid, op->o_client_msgid );
 
-        needle.o_client_msgid = netnum;
+        CONNECTION_UNLOCK_INCREF(c);
+        operation_send_reject(
+                op, LDAP_PROTOCOL_ERROR, "invalid PDU received", 0 );
+        CONNECTION_LOCK_DECREF(c);
+        CLIENT_DESTROY(c);
+        return -1;
     }
 
     request = tavl_find( c->c_ops, &needle, operation_client_cmp );