summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-06-20 04:15:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:53:26 -0500
commitd291b8bf933e7595ac2967602d90918c286e3429 (patch)
treed9ba06a19ecdd22052e23856c181fcf5f81c280e
parent576b1c84fb9c5de642b549d769764488436f2c5f (diff)
downloadsamba-d291b8bf933e7595ac2967602d90918c286e3429.tar.gz
samba-d291b8bf933e7595ac2967602d90918c286e3429.tar.bz2
samba-d291b8bf933e7595ac2967602d90918c286e3429.zip
r23551: Change data_blob_equal to data_blob_cmp, suitable for sorting with qsort().
Andrew Bartlett (This used to be commit 96ef5259c63ad6245c94c40d6059d736b1534183)
-rw-r--r--source4/lib/registry/patchfile.c2
-rw-r--r--source4/lib/util/data_blob.c22
-rw-r--r--source4/librpc/rpc/dcerpc.c4
-rw-r--r--source4/rpc_server/epmapper/rpc_epmapper.c4
-rw-r--r--source4/torture/basic/aliases.c4
5 files changed, 19 insertions, 17 deletions
diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c
index bb37e4bb6a..8bbca07962 100644
--- a/source4/lib/registry/patchfile.c
+++ b/source4/lib/registry/patchfile.c
@@ -125,7 +125,7 @@ static WERROR reg_generate_diff_key(struct reg_diff *diff, struct registry_key *
return error2;
}
- if (W_ERROR_IS_OK(error2) && data_blob_equal(&v1->data, &v2->data))
+ if (W_ERROR_IS_OK(error2) && data_blob_cmp(&v1->data, &v2->data) == 0)
continue;
thiskey = diff_find_add_key(diff, oldkey->path);
diff --git a/source4/lib/util/data_blob.c b/source4/lib/util/data_blob.c
index e04bd65331..ca04b70eb2 100644
--- a/source4/lib/util/data_blob.c
+++ b/source4/lib/util/data_blob.c
@@ -130,21 +130,23 @@ _PUBLIC_ void data_blob_clear_free(DATA_BLOB *d)
/**
check if two data blobs are equal
**/
-_PUBLIC_ BOOL data_blob_equal(const DATA_BLOB *d1, const DATA_BLOB *d2)
+_PUBLIC_ int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2)
{
- if (d1->length != d2->length) {
- return False;
+ int ret;
+ if (d1->data == NULL && d2->data != NULL) {
+ return -1;
}
- if (d1->data == d2->data) {
- return True;
+ if (d1->data != NULL && d2->data == NULL) {
+ return 1;
}
- if (d1->data == NULL || d2->data == NULL) {
- return False;
+ if (d1->data == d2->data) {
+ return d1->length - d2->length;
}
- if (memcmp(d1->data, d2->data, d1->length) == 0) {
- return True;
+ ret = memcmp(d1->data, d2->data, MIN(d1->length, d2->length));
+ if (ret == 0) {
+ return d1->length - d2->length;
}
- return False;
+ return ret;
}
/**
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index 4e46093573..8142df785b 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -1193,7 +1193,7 @@ static NTSTATUS dcerpc_ndr_validate_in(struct dcerpc_connection *c,
blob2 = ndr_push_blob(push);
- if (!data_blob_equal(&blob, &blob2)) {
+ if (data_blob_cmp(&blob, &blob2) != 0) {
DEBUG(3,("original:\n"));
dump_data(3, blob.data, blob.length);
DEBUG(3,("secondary:\n"));
@@ -1276,7 +1276,7 @@ static NTSTATUS dcerpc_ndr_validate_out(struct dcerpc_connection *c,
blob2 = ndr_push_blob(push);
- if (!data_blob_equal(&blob, &blob2)) {
+ if (data_blob_cmp(&blob, &blob2) != 0) {
DEBUG(3,("original:\n"));
dump_data(3, blob.data, blob.length);
DEBUG(3,("secondary:\n"));
diff --git a/source4/rpc_server/epmapper/rpc_epmapper.c b/source4/rpc_server/epmapper/rpc_epmapper.c
index 2f2d406cbd..1a736db629 100644
--- a/source4/rpc_server/epmapper/rpc_epmapper.c
+++ b/source4/rpc_server/epmapper/rpc_epmapper.c
@@ -218,8 +218,8 @@ static error_status_t dcesrv_epm_Map(struct dcesrv_call_state *dce_call, TALLOC_
for (i=0;i<count;i++) {
if (
- !data_blob_equal(&r->in.map_tower->tower.floors[0].lhs.lhs_data,
- &eps[i].ep.floors[0].lhs.lhs_data)
+ data_blob_cmp(&r->in.map_tower->tower.floors[0].lhs.lhs_data,
+ &eps[i].ep.floors[0].lhs.lhs_data) != 0
|| transport != dcerpc_transport_by_tower(&eps[i].ep)) {
continue;
}
diff --git a/source4/torture/basic/aliases.c b/source4/torture/basic/aliases.c
index bf052cf5cc..78daf3206b 100644
--- a/source4/torture/basic/aliases.c
+++ b/source4/torture/basic/aliases.c
@@ -68,8 +68,8 @@ static bool gen_aliases(struct torture_context *tctx,
for (t2b=alias_blobs; t2b; t2b=t2b->next) {
for (t2b2=alias_blobs; t2b2; t2b2=t2b2->next) {
if (t2b->level >= t2b2->level) continue;
- if (data_blob_equal(&t2b->params, &t2b2->params) &&
- data_blob_equal(&t2b->data, &t2b2->data)) {
+ if (data_blob_cmp(&t2b->params, &t2b2->params) == 0 &&
+ data_blob_cmp(&t2b->data, &t2b2->data) == 0) {
torture_comment(tctx,
"\tLevel %u (0x%x) and level %u (0x%x) are possible aliases\n",
t2b->level, t2b->level, t2b2->level, t2b2->level);