[PATCH] A few small ones
Volker Lendecke
vl at samba.org
Tue Sep 27 00:54:33 UTC 2016
Hi!
Review appreciated!
Thanks, Volker
-------------- next part --------------
>From b9bb484dc20bfac46c47412a73f0c9c0ab877f4f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 26 Sep 2016 08:16:15 -0700
Subject: [PATCH 1/4] lib: Only return "rec" on demand in
messaging_filtered_read_recv
The message could be just a trigger without contents.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/messages.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 3ed6dfe..ef5d679 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -650,7 +650,9 @@ int messaging_filtered_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
tevent_req_received(req);
return err;
}
- *presult = talloc_move(mem_ctx, &state->rec);
+ if (presult != NULL) {
+ *presult = talloc_move(mem_ctx, &state->rec);
+ }
return 0;
}
--
2.7.4
>From 314f9555097d9620666ca6f8a13fe30cc6c05d12 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 18 Sep 2016 14:03:33 +0200
Subject: [PATCH 2/4] wbclient: "ev" is no longer used in wbc_sids_to_xids
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/auth/unix_token.c | 2 +-
source4/libcli/wbclient/wbclient.c | 3 +--
source4/libcli/wbclient/wbclient.h | 3 +--
source4/ntvfs/posix/pvfs_acl.c | 6 ++----
source4/ntvfs/posix/pvfs_acl_nfs4.c | 3 +--
source4/rpc_server/unixinfo/dcesrv_unixinfo.c | 4 ++--
6 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/source4/auth/unix_token.c b/source4/auth/unix_token.c
index efc9a9d..385109b 100644
--- a/source4/auth/unix_token.c
+++ b/source4/auth/unix_token.c
@@ -55,7 +55,7 @@ NTSTATUS security_token_to_unix_token(TALLOC_CTX *mem_ctx,
ids[s].status = ID_UNKNOWN;
}
- status = wbc_sids_to_xids(ev, ids, token->num_sids);
+ status = wbc_sids_to_xids(ids, token->num_sids);
NT_STATUS_NOT_OK_RETURN(status);
g = token->num_sids;
diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c
index f306556..1ff35c8 100644
--- a/source4/libcli/wbclient/wbclient.c
+++ b/source4/libcli/wbclient/wbclient.c
@@ -26,8 +26,7 @@
#include "libcli/security/dom_sid.h"
#include "nsswitch/libwbclient/wbclient.h"
-NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, struct id_map *ids,
- uint32_t count)
+NTSTATUS wbc_sids_to_xids(struct id_map *ids, uint32_t count)
{
TALLOC_CTX *mem_ctx;
uint32_t i;
diff --git a/source4/libcli/wbclient/wbclient.h b/source4/libcli/wbclient/wbclient.h
index fc096cc..1300c73 100644
--- a/source4/libcli/wbclient/wbclient.h
+++ b/source4/libcli/wbclient/wbclient.h
@@ -20,8 +20,7 @@
*/
#include "librpc/gen_ndr/idmap.h"
-NTSTATUS wbc_sids_to_xids(struct tevent_context *ev, struct id_map *ids,
- uint32_t count);
+NTSTATUS wbc_sids_to_xids(struct id_map *ids, uint32_t count);
NTSTATUS wbc_xids_to_sids(struct tevent_context *ev, struct id_map *ids,
uint32_t count);
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index 269b5ec..be12ef2 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -330,8 +330,7 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs,
}
if (!dom_sid_equal(sd->owner_sid, new_sd->owner_sid)) {
ids->sid = new_sd->owner_sid;
- status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx,
- ids, 1);
+ status = wbc_sids_to_xids(ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
@@ -348,8 +347,7 @@ NTSTATUS pvfs_acl_set(struct pvfs_state *pvfs,
}
if (!dom_sid_equal(sd->group_sid, new_sd->group_sid)) {
ids->sid = new_sd->group_sid;
- status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx,
- ids, 1);
+ status = wbc_sids_to_xids(ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
diff --git a/source4/ntvfs/posix/pvfs_acl_nfs4.c b/source4/ntvfs/posix/pvfs_acl_nfs4.c
index dbb43e2..948ddb2 100644
--- a/source4/ntvfs/posix/pvfs_acl_nfs4.c
+++ b/source4/ntvfs/posix/pvfs_acl_nfs4.c
@@ -155,8 +155,7 @@ static NTSTATUS pvfs_acl_save_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
ids[i].status = ID_UNKNOWN;
}
- status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx, ids,
- acl.a_count);
+ status = wbc_sids_to_xids(ids, acl.a_count);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
return status;
diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
index 10eda45..771e4fd 100644
--- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
+++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
@@ -40,7 +40,7 @@ static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
ids->sid = &r->in.sid;
ids->status = ID_UNKNOWN;
ZERO_STRUCT(ids->xid);
- status = wbc_sids_to_xids(dce_call->event_ctx, ids, 1);
+ status = wbc_sids_to_xids(ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
@@ -99,7 +99,7 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call,
ids->sid = &r->in.sid;
ids->status = ID_UNKNOWN;
ZERO_STRUCT(ids->xid);
- status = wbc_sids_to_xids(dce_call->event_ctx, ids, 1);
+ status = wbc_sids_to_xids(ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
if (ids->xid.type == ID_TYPE_BOTH ||
--
2.7.4
>From 6825b234d80a21911e480e58d3e6e973d4a96228 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 18 Sep 2016 14:06:24 +0200
Subject: [PATCH 3/4] wbclient: "ev" is no longer used in wbc_xids_to_sids
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/libcli/wbclient/wbclient.c | 3 +--
source4/libcli/wbclient/wbclient.h | 3 +--
source4/ntvfs/posix/pvfs_acl.c | 4 ++--
source4/ntvfs/posix/pvfs_acl_nfs4.c | 2 +-
source4/rpc_server/unixinfo/dcesrv_unixinfo.c | 4 ++--
5 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c
index 1ff35c8..69d8b43 100644
--- a/source4/libcli/wbclient/wbclient.c
+++ b/source4/libcli/wbclient/wbclient.c
@@ -102,8 +102,7 @@ NTSTATUS wbc_sids_to_xids(struct id_map *ids, uint32_t count)
return NT_STATUS_OK;
}
-NTSTATUS wbc_xids_to_sids(struct tevent_context *ev, struct id_map *ids,
- uint32_t count)
+NTSTATUS wbc_xids_to_sids(struct id_map *ids, uint32_t count)
{
TALLOC_CTX *mem_ctx;
uint32_t i;
diff --git a/source4/libcli/wbclient/wbclient.h b/source4/libcli/wbclient/wbclient.h
index 1300c73..6334428 100644
--- a/source4/libcli/wbclient/wbclient.h
+++ b/source4/libcli/wbclient/wbclient.h
@@ -22,5 +22,4 @@
NTSTATUS wbc_sids_to_xids(struct id_map *ids, uint32_t count);
-NTSTATUS wbc_xids_to_sids(struct tevent_context *ev, struct id_map *ids,
- uint32_t count);
+NTSTATUS wbc_xids_to_sids(struct id_map *ids, uint32_t count);
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index be12ef2..b298764 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -169,7 +169,7 @@ static NTSTATUS pvfs_default_acl(struct pvfs_state *pvfs,
ids[1].xid.type = ID_TYPE_GID;
ids[1].sid = NULL;
- status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, 2);
+ status = wbc_xids_to_sids(ids, 2);
NT_STATUS_NOT_OK_RETURN(status);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
@@ -995,7 +995,7 @@ NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,
ids[1].sid = NULL;
ids[1].status = ID_UNKNOWN;
- status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, 2);
+ status = wbc_xids_to_sids(ids, 2);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
return status;
diff --git a/source4/ntvfs/posix/pvfs_acl_nfs4.c b/source4/ntvfs/posix/pvfs_acl_nfs4.c
index 948ddb2..bd00794 100644
--- a/source4/ntvfs/posix/pvfs_acl_nfs4.c
+++ b/source4/ntvfs/posix/pvfs_acl_nfs4.c
@@ -90,7 +90,7 @@ static NTSTATUS pvfs_acl_load_nfs4(struct pvfs_state *pvfs, struct pvfs_filename
/* Allocate memory for the sids from the security descriptor to be on
* the safe side. */
- status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, num_ids);
+ status = wbc_xids_to_sids(ids, num_ids);
NT_STATUS_NOT_OK_RETURN(status);
sd->owner_sid = talloc_steal(sd, ids[0].sid);
diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
index 771e4fd..848c11f 100644
--- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
+++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c
@@ -77,7 +77,7 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call,
ids->xid.id = uid;
ids->xid.type = ID_TYPE_UID;
- status = wbc_xids_to_sids(dce_call->event_ctx, ids, 1);
+ status = wbc_xids_to_sids(ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
r->out.sid = ids->sid;
@@ -136,7 +136,7 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call,
ids->xid.id = gid;
ids->xid.type = ID_TYPE_GID;
- status = wbc_xids_to_sids(dce_call->event_ctx, ids, 1);
+ status = wbc_xids_to_sids(ids, 1);
NT_STATUS_NOT_OK_RETURN(status);
r->out.sid = ids->sid;
--
2.7.4
>From 4fd18e3ef93901b23877273d826dd9a9a85d0c24 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 22 Jul 2016 15:59:32 +0200
Subject: [PATCH 4/4] messaging: Add wrap check to messaging_rec_dup
Just paranoia
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/messages.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index ef5d679..3e11cc5 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -496,9 +496,16 @@ static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx,
{
struct messaging_rec *result;
size_t fds_size = sizeof(int64_t) * rec->num_fds;
+ size_t payload_len;
+
+ payload_len = rec->buf.length + fds_size;
+ if (payload_len < rec->buf.length) {
+ /* overflow */
+ return NULL;
+ }
result = talloc_pooled_object(mem_ctx, struct messaging_rec, 2,
- rec->buf.length + fds_size);
+ payload_len);
if (result == NULL) {
return NULL;
}
--
2.7.4
More information about the samba-technical
mailing list