summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-12-19 14:22:28 +0100
committerVolker Lendecke <vlendec@samba.org>2010-12-20 00:12:02 +0100
commit49dc973586b4b9b72ffcac3bbb5dc7fda0d1ad4e (patch)
tree1813e791ba68c43b065e13a7338589c1df61e173
parentfd49ed238c5e82c8444eec35a09c32c191b76074 (diff)
downloadsamba-49dc973586b4b9b72ffcac3bbb5dc7fda0d1ad4e.tar.gz
samba-49dc973586b4b9b72ffcac3bbb5dc7fda0d1ad4e.tar.bz2
samba-49dc973586b4b9b72ffcac3bbb5dc7fda0d1ad4e.zip
lib: Protect against tevent nterror mismatches
Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Mon Dec 20 00:12:02 CET 2010 on sn-devel-104
-rw-r--r--lib/util/tevent_ntstatus.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/util/tevent_ntstatus.c b/lib/util/tevent_ntstatus.c
index c4dd0740dc..764d251b59 100644
--- a/lib/util/tevent_ntstatus.c
+++ b/lib/util/tevent_ntstatus.c
@@ -20,12 +20,29 @@
#include "../replace/replace.h"
#include "tevent_ntstatus.h"
+#define TEVENT_NTERROR_MAGIC (0x917b5acd)
+
bool _tevent_req_nterror(struct tevent_req *req,
NTSTATUS status,
const char *location)
{
- return _tevent_req_error(req, NT_STATUS_V(status),
- location);
+ uint64_t err;
+
+ if (NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ /*
+ * I've put this variable here, because I'm not 100% certain
+ * how to correctly assign a 64-bit constant and left-shift it
+ * by 32 bits in a single expression. If anyone knows, feel
+ * free :-)
+ */
+ err = TEVENT_NTERROR_MAGIC;
+ err <<= 32;
+ err |= NT_STATUS_V(status);
+
+ return _tevent_req_error(req, err, location);
}
bool tevent_req_is_nterror(struct tevent_req *req, NTSTATUS *status)
@@ -44,7 +61,10 @@ bool tevent_req_is_nterror(struct tevent_req *req, NTSTATUS *status)
*status = NT_STATUS_NO_MEMORY;
break;
case TEVENT_REQ_USER_ERROR:
- *status = NT_STATUS(err);
+ if ((err >> 32) != TEVENT_NTERROR_MAGIC) {
+ abort();
+ }
+ *status = NT_STATUS(err & 0xffffffff);
break;
default:
*status = NT_STATUS_INTERNAL_ERROR;