libcli/security: fix sid_type_lookup().
[kai/samba.git] / libcli / ldap / ldap_message.c
index e5b94b8df122d839ace939fa2eb9542b9feb4b97..7756e731b247fd08796c0303d228dd5eaf098d22 100644 (file)
@@ -167,6 +167,12 @@ static bool ldap_encode_control(void *mem_ctx, struct asn1_data *data,
        }
 
        for (i = 0; handlers[i].oid != NULL; i++) {
+               if (!ctrl->oid) {
+                       /* not encoding this control, the OID has been
+                        * set to NULL indicating it isn't really
+                        * here */
+                       return true;
+               }
                if (strcmp(handlers[i].oid, ctrl->oid) == 0) {
                        if (!handlers[i].encode) {
                                if (ctrl->critical) {
@@ -1611,5 +1617,12 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data,
 */
 NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size)
 {
+       if (blob.length < 6) {
+               /*
+                * We need at least 6 bytes to workout the length
+                * of the pdu.
+                */
+               return STATUS_MORE_ENTRIES;
+       }
        return asn1_peek_full_tag(blob, ASN1_SEQUENCE(0), packet_size);
 }