s4-ldb: use GUID_to_ndr_blob()
authorAndrew Tridgell <tridge@samba.org>
Thu, 10 Dec 2009 03:32:47 +0000 (14:32 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 10 Dec 2009 06:51:29 +0000 (17:51 +1100)
source4/lib/ldb-samba/ldif_handlers.c
source4/lib/ldb/common/ldb_dn.c

index 86bb1a1c7c5eeb72a3adf228021b7acadac0c259..27aa749f36fee685fe5811639b6d5a9988e92118 100644 (file)
@@ -215,16 +215,14 @@ static int ldif_read_objectGUID(struct ldb_context *ldb, void *mem_ctx,
 {
        struct GUID guid;
        NTSTATUS status;
-       enum ndr_err_code ndr_err;
 
        status = GUID_from_data_blob(in, &guid);
        if (!NT_STATUS_IS_OK(status)) {
                return -1;
        }
 
-       ndr_err = ndr_push_struct_blob(out, mem_ctx, NULL, &guid,
-                                      (ndr_push_flags_fn_t)ndr_push_GUID);
-       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+       status = GUID_to_ndr_blob(&guid, mem_ctx, out);
+       if (!NT_STATUS_IS_OK(status)) {
                return -1;
        }
        return 0;
index 3721fa733352de3e7c7009271591d3bfd6686d9f..63cec8995305972c90ff512665d189670e2bf108 100644 (file)
@@ -232,7 +232,7 @@ static int ldb_dn_escape_internal(char *dst, const char *src, int len)
                        /* any others get \XX form */
                        unsigned char v;
                        const char *hexbytes = "0123456789ABCDEF";
-                       v = *(unsigned char *)p;
+                       v = *(const unsigned char *)p;
                        *d++ = '\\';
                        *d++ = hexbytes[v>>4];
                        *d++ = hexbytes[v&0xF];
@@ -1901,6 +1901,11 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
                }
        }
 
+       if (val == NULL) {
+               /* removing a value that doesn't exist is not an error */
+               return LDB_SUCCESS;
+       }
+
        p = dn->ext_components
                = talloc_realloc(dn,
                                 dn->ext_components,