summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-03-07 23:10:37 +0000
committerJeremy Allison <jra@samba.org>2001-03-07 23:10:37 +0000
commita65db7a8b817fde73e850ce144377c53e14c2925 (patch)
treeb7fe45970456927de81d8cf7d21e1de7731c7675 /source
parentb3e36b35b8f1b42b77a70de3006bdafdba47406c (diff)
downloadsamba-a65db7a8b817fde73e850ce144377c53e14c2925.tar.gz
Correctly marshall "POLICY_HND" structs accross all uses.
Jeremy.
Diffstat (limited to 'source')
-rw-r--r--source/include/rpc_misc.h10
-rwxr-xr-xsource/include/rpc_spoolss.h2
-rw-r--r--source/lib/util_list.c11
-rw-r--r--source/rpc_client/cli_lsarpc.c14
-rw-r--r--source/rpc_client/cli_reg.c14
-rw-r--r--source/rpc_client/cli_samr.c6
-rw-r--r--source/rpc_parse/parse_misc.c13
-rw-r--r--source/rpc_server/srv_lsa_hnd.c21
-rw-r--r--source/rpc_server/srv_lsa_nt.c10
-rw-r--r--source/rpc_server/srv_reg_nt.c2
-rw-r--r--source/rpc_server/srv_spoolss_nt.c17
11 files changed, 59 insertions, 61 deletions
diff --git a/source/include/rpc_misc.h b/source/include/rpc_misc.h
index 1fbf87f134f..5152df8e0f4 100644
--- a/source/include/rpc_misc.h
+++ b/source/include/rpc_misc.h
@@ -288,16 +288,16 @@ typedef struct gid_info
} DOM_GID;
-#define POL_HND_SIZE 20
-
/* POLICY_HND */
typedef struct lsa_policy_info
{
- uint8 data[POL_HND_SIZE]; /* policy handle */
-
+ uint32 data1;
+ uint32 data2;
+ uint16 data3;
+ uint16 data4;
+ uint8 data5[8];
} POLICY_HND;
-
/*
* A client connection's state, pipe name,
* user credentials, etc...
diff --git a/source/include/rpc_spoolss.h b/source/include/rpc_spoolss.h
index 82719b6bc9b..798b32bb7ec 100755
--- a/source/include/rpc_spoolss.h
+++ b/source/include/rpc_spoolss.h
@@ -193,8 +193,6 @@
#define JOB_WRITE STANDARD_RIGHTS_WRITE_ACCESS|JOB_ACCESS_ADMINISTER
#define JOB_EXECUTE STANDARD_RIGHTS_EXECUTE_ACCESS|JOB_ACCESS_ADMINISTER
-#define POLICY_HND_SIZE 20
-
#define ONE_VALUE 01
#define TWO_VALUE 02
#define POINTER 03
diff --git a/source/lib/util_list.c b/source/lib/util_list.c
index ea262b5db52..19354c87843 100644
--- a/source/lib/util_list.c
+++ b/source/lib/util_list.c
@@ -193,8 +193,6 @@ static void* generic_list_locate (GENERIC_LIST *l, void *search,
*************************************************************/
BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src)
{
- int i;
-
/* if we have no destination, return an error */
if (dest == NULL)
return False;
@@ -205,14 +203,11 @@ BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src)
{
/* if POLICY_HND internals ever changes,
this will need to be fixed */
- memset (dest->data, 0, POLICY_HND_SIZE);
+ ZERO_STRUCTP(dest);
return True;
}
- /* copy the src handle to the dest */
- for (i=0; i<POLICY_HND_SIZE; i++)
- dest->data[i] = src->data[i];
-
+ *dest = *src;
return True;
}
@@ -240,7 +235,7 @@ BOOL compare_rpc_hnd_node(const RPC_HND_NODE *x,
/* if the POLICY_HND field(s) are ever changed, this
will need to be updated. Probably should be a set of
support function for dealing with POLICY_HND */
- return (memcmp(x->hnd.data, y->hnd.data, POLICY_HND_SIZE) == 0);
+ return (memcmp(&x->hnd, &y->hnd, sizeof(POLICY_HND)) == 0);
}
/***************************************************************
diff --git a/source/rpc_client/cli_lsarpc.c b/source/rpc_client/cli_lsarpc.c
index 03a5cad7093..9ba13552bc5 100644
--- a/source/rpc_client/cli_lsarpc.c
+++ b/source/rpc_client/cli_lsarpc.c
@@ -87,7 +87,7 @@ BOOL do_lsa_open_policy(struct cli_state *cli,
return False;
} else {
/* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
+ *hnd = r_o.pol;
}
prs_mem_free(&rbuf);
@@ -207,7 +207,6 @@ BOOL do_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
prs_struct buf;
LSA_Q_CLOSE q_c;
LSA_R_CLOSE r_c;
- int i;
if (hnd == NULL)
return False;
@@ -252,12 +251,11 @@ BOOL do_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
/* check that the returned policy handle is all zeros */
- for (i = 0; i < sizeof(r_c.pol.data); i++) {
- if (r_c.pol.data[i] != 0) {
- DEBUG(0,("LSA_CLOSE: non-zero handle returned\n"));
- prs_mem_free(&rbuf);
- return False;
- }
+ if (IVAL(&r_c.pol.data1,0) || IVAL(&r_c.pol.data2,0) || SVAL(&r_c.pol.data3,0) ||
+ SVAL(&r_c.pol.data4,0) || IVAL(r_c.pol.data5,0) || IVAL(r_c.pol.data5,4) ) {
+ DEBUG(0,("LSA_CLOSE: non-zero handle returned\n"));
+ prs_mem_free(&rbuf);
+ return False;
}
prs_mem_free(&rbuf);
diff --git a/source/rpc_client/cli_reg.c b/source/rpc_client/cli_reg.c
index 96e27c5ce66..32439e9b5d4 100644
--- a/source/rpc_client/cli_reg.c
+++ b/source/rpc_client/cli_reg.c
@@ -126,7 +126,7 @@ BOOL do_reg_open_hklm(struct cli_state *cli, uint16 unknown_0, uint32 level,
}
/* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
+ *hnd = r_o.pol;
prs_mem_free(&rbuf);
@@ -187,7 +187,7 @@ BOOL do_reg_open_hku(struct cli_state *cli, uint16 unknown_0, uint32 level,
}
/* ok, at last: we're happy. return the policy handle */
- memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
+ *hnd = r_o.pol;
prs_mem_free(&rbuf);
@@ -755,7 +755,7 @@ BOOL do_reg_create_key(struct cli_state *cli, POLICY_HND *hnd,
return False;
}
- memcpy(key, r_o.key_pol.data, sizeof(key->data));
+ *key = r_o.key_pol;
prs_mem_free(&rbuf);
@@ -1003,7 +1003,7 @@ BOOL do_reg_open_entry(struct cli_state *cli, POLICY_HND *hnd,
return False;
}
- memcpy(key_hnd, r_o.pol.data, sizeof(key_hnd->data));
+ *key_hnd = r_o.pol;
prs_mem_free(&rbuf);
@@ -1019,7 +1019,6 @@ BOOL do_reg_close(struct cli_state *cli, POLICY_HND *hnd)
prs_struct buf;
REG_Q_CLOSE q_c;
REG_R_CLOSE r_c;
- int i;
if (hnd == NULL)
return False;
@@ -1066,12 +1065,11 @@ BOOL do_reg_close(struct cli_state *cli, POLICY_HND *hnd)
/* check that the returned policy handle is all zeros */
- for (i = 0; i < sizeof(r_c.pol.data); i++) {
- if (r_c.pol.data[i] != 0) {
+ if (IVAL(&r_c.pol.data1,0) || IVAL(&r_c.pol.data2,0) || SVAL(&r_c.pol.data3,0) ||
+ SVAL(&r_c.pol.data4,0) || IVAL(r_c.pol.data5,0) || IVAL(r_c.pol.data5,4) ) {
prs_mem_free(&rbuf);
DEBUG(0,("REG_CLOSE: non-zero handle returned\n"));
return False;
- }
}
prs_mem_free(&rbuf);
diff --git a/source/rpc_client/cli_samr.c b/source/rpc_client/cli_samr.c
index 5553041d35b..959779d8fcf 100644
--- a/source/rpc_client/cli_samr.c
+++ b/source/rpc_client/cli_samr.c
@@ -789,7 +789,6 @@ BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd)
prs_struct rdata;
SAMR_Q_CLOSE_HND q_c;
SAMR_R_CLOSE_HND r_c;
- int i;
if (hnd == NULL)
return False;
@@ -834,12 +833,11 @@ BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd)
/* check that the returned policy handle is all zeros */
- for (i = 0; i < sizeof(r_c.pol.data); i++) {
- if (r_c.pol.data[i] != 0) {
+ if (IVAL(&r_c.pol.data1,0) || IVAL(&r_c.pol.data2,0) || SVAL(&r_c.pol.data3,0) ||
+ SVAL(&r_c.pol.data4,0) || IVAL(r_c.pol.data5,0) || IVAL(r_c.pol.data5,4) ) {
DEBUG(0,("SAMR_CLOSE_HND: non-zero handle returned\n"));
prs_mem_free(&rdata);
return False;
- }
}
prs_mem_free(&rdata);
diff --git a/source/rpc_parse/parse_misc.c b/source/rpc_parse/parse_misc.c
index 0a65c09493a..81602a1dc40 100644
--- a/source/rpc_parse/parse_misc.c
+++ b/source/rpc_parse/parse_misc.c
@@ -1438,8 +1438,19 @@ BOOL smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
if(!prs_align(ps))
return False;
+
+ if(UNMARSHALLING(ps))
+ ZERO_STRUCTP(pol);
- if(!prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE))
+ if (!prs_uint32("data1", ps, depth, &pol->data1))
+ return False;
+ if (!prs_uint32("data2", ps, depth, &pol->data2))
+ return False;
+ if (!prs_uint16("data3", ps, depth, &pol->data3))
+ return False;
+ if (!prs_uint16("data4", ps, depth, &pol->data4))
+ return False;
+ if(!prs_uint8s (False, "data5", ps, depth, pol->data5, sizeof(pol->data5)))
return False;
return True;
diff --git a/source/rpc_server/srv_lsa_hnd.c b/source/rpc_server/srv_lsa_hnd.c
index a0d2bdbca0f..ffbb96acc62 100644
--- a/source/rpc_server/srv_lsa_hnd.c
+++ b/source/rpc_server/srv_lsa_hnd.c
@@ -71,11 +71,14 @@ static void create_pol_hnd(POLICY_HND *hnd)
pol_hnd_low++;
if (pol_hnd_low == 0) pol_hnd_high++;
- SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */
- SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */
- SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */
- SIVAL(hnd->data, 12, time(NULL)); /* something random */
- SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
+ ZERO_STRUCTP(hnd);
+
+ SIVAL(&hnd->data1, 0 , 0x0); /* first bit must be null */
+ SIVAL(&hnd->data2, 0 , pol_hnd_low ); /* second bit is incrementing */
+ SSVAL(&hnd->data3, 0 , pol_hnd_high); /* second bit is incrementing */
+ SSVAL(&hnd->data4, 0 , (pol_hnd_high>>16)); /* second bit is incrementing */
+ SIVAL(hnd->data5, 0, time(NULL)); /* something random */
+ SIVAL(hnd->data5, 4, sys_getpid()); /* something more random */
}
/****************************************************************************
@@ -116,14 +119,14 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd)
p->pnum = i;
create_pol_hnd(hnd);
- memcpy(&p->pol_hnd, hnd, sizeof(*hnd));
+ p->pol_hnd = *hnd;
bitmap_set(bmap, i);
DLIST_ADD(Policy, p);
DEBUG(4,("Opened policy hnd[%x] ", i));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (char *)hnd, sizeof(hnd));
return True;
}
@@ -138,13 +141,13 @@ static struct policy *find_lsa_policy(POLICY_HND *hnd)
for (p=Policy;p;p=p->next) {
if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) {
DEBUG(4,("Found policy hnd[%x] ", p->pnum));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (char *)hnd, sizeof(hnd));
return p;
}
}
DEBUG(4,("Policy not found: "));
- dump_data(4, (char *)hnd->data, sizeof(hnd->data));
+ dump_data(4, (char *)hnd, sizeof(hnd));
return NULL;
}
diff --git a/source/rpc_server/srv_lsa_nt.c b/source/rpc_server/srv_lsa_nt.c
index 0e6027fd8ea..f15dd4a3adf 100644
--- a/source/rpc_server/srv_lsa_nt.c
+++ b/source/rpc_server/srv_lsa_nt.c
@@ -280,14 +280,11 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u)
{
- int i;
-
/* lkclXXXX having decoded it, ignore all fields in the open policy! */
/* set up the LSA QUERY INFO response */
- for (i = 4; i < POL_HND_SIZE; i++)
- r_u->pol.data[i] = i;
+ ZERO_STRUCT(r_u->pol);
return NT_STATUS_NOPROBLEMO;
}
@@ -298,14 +295,11 @@ uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2
uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u)
{
- int i;
-
/* lkclXXXX having decoded it, ignore all fields in the open policy! */
/* set up the LSA QUERY INFO response */
- for (i = 4; i < POL_HND_SIZE; i++)
- r_u->pol.data[i] = i;
+ ZERO_STRUCT(r_u->pol);
return NT_STATUS_NOPROBLEMO;
}
diff --git a/source/rpc_server/srv_reg_nt.c b/source/rpc_server/srv_reg_nt.c
index a95deb2814b..ebf8621f8e3 100644
--- a/source/rpc_server/srv_reg_nt.c
+++ b/source/rpc_server/srv_reg_nt.c
@@ -36,7 +36,7 @@ extern int DEBUGLEVEL;
uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u)
{
/* set up the REG unknown_1 response */
- memset((char *)r_u->pol.data, '\0', POL_HND_SIZE);
+ ZERO_STRUCT(r_u->pol);
/* close the policy handle */
if (!close_lsa_policy_hnd(&q_u->pol))
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index cfacb7ff7c4..0f1342b6e16 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -83,8 +83,8 @@ static ubi_dlList counter_list;
static struct cli_state cli;
static uint32 smb_connections=0;
-#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data,16)==(uint32)sys_getpid()))
-#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data,16)==sys_getpid()?"OURS":"OTHER"))
+#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data5,4)==(uint32)sys_getpid()))
+#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER"))
/* translate between internal status numbers and NT status numbers */
static int nt_printj_status(int v)
@@ -218,11 +218,14 @@ static void create_printer_hnd(POLICY_HND *hnd)
prt_hnd_low++;
if (prt_hnd_low == 0) prt_hnd_high++;
- SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */
- SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */
- SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */
- SIVAL(hnd->data, 12, time(NULL)); /* something random */
- SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
+ ZERO_STRUCTP(hnd);
+
+ SIVAL(&hnd->data1, 0 , 0x0); /* first bit must be null */
+ SIVAL(&hnd->data2, 0 , prt_hnd_low ); /* second bit is incrementing */
+ SSVAL(&hnd->data3, 0 , prt_hnd_high); /* second bit is incrementing */
+ SSVAL(&hnd->data4, 0 , (prt_hnd_high>>16)); /* second bit is incrementing */
+ SIVAL(hnd->data5, 0, time(NULL)); /* something random */
+ SIVAL(hnd->data5, 4, sys_getpid()); /* something more random */
}
/****************************************************************************