229
229
/*******************************************************************
230
Inits a DOM_SID structure.
232
BIG NOTE: this function only does SIDS where the identauth is not >= 2^32
233
identauth >= 2^32 can be detected because it will be specified in hex
234
********************************************************************/
236
void init_dom_sid(DOM_SID *sid, const char *str_sid)
242
if (str_sid == NULL) {
243
DEBUG(4,("netlogon domain SID: none\n"));
244
sid->sid_rev_num = 0;
249
pstrcpy(domsid, str_sid);
251
DEBUG(4,("init_dom_sid %d SID: %s\n", __LINE__, domsid));
253
/* assume, but should check, that domsid starts "S-" */
254
p = strtok(domsid+2,"-");
255
sid->sid_rev_num = atoi(p);
257
/* identauth in decimal should be < 2^32 */
258
/* identauth in hex should be >= 2^32 */
259
identauth = atoi(strtok(0,"-"));
261
DEBUG(4,("netlogon rev %d\n", sid->sid_rev_num));
262
DEBUG(4,("netlogon %s ia %d\n", p, identauth));
266
sid->id_auth[2] = (identauth & 0xff000000) >> 24;
267
sid->id_auth[3] = (identauth & 0x00ff0000) >> 16;
268
sid->id_auth[4] = (identauth & 0x0000ff00) >> 8;
269
sid->id_auth[5] = (identauth & 0x000000ff);
273
while ((p = strtok(0, "-")) != NULL && sid->num_auths < MAXSUBAUTHS)
274
sid->sub_auths[sid->num_auths++] = atoi(p);
276
DEBUG(4,("init_dom_sid: %d SID: %s\n", __LINE__, domsid));
279
/*******************************************************************
280
230
Inits a DOM_SID2 structure.
281
231
********************************************************************/
598
548
/* set up string lengths. */
599
549
str->buf_len = create_rpc_blob(str, len*2);
600
rpcstr_push(str->buffer, buf, str->buf_len, STR_TERMINATE);
550
rpcstr_push(str->buffer, buf, (size_t)str->buf_len, STR_TERMINATE);
762
712
/* set up string lengths. */
763
713
SMB_ASSERT(max_len >= str_len);
715
/* Ensure buf is valid if str_len was set. Coverity check. */
716
if (str_len && !buf) {
765
720
str->str_max_len = max_len;
767
722
str->str_str_len = str_len;
879
834
void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags)
881
836
uni4->string = TALLOC_P( get_talloc_ctx(), UNISTR2 );
838
smb_panic("init_unistr4: talloc fail\n");
882
841
init_unistr2( uni4->string, buf, flags );
884
843
uni4->length = 2 * (uni4->string->uni_str_len);
888
847
void init_unistr4_w( TALLOC_CTX *ctx, UNISTR4 *uni4, const smb_ucs2_t *buf )
890
849
uni4->string = TALLOC_P( ctx, UNISTR2 );
851
smb_panic("init_unistr4_w: talloc fail\n");
891
854
init_unistr2_w( ctx, uni4->string, buf );
893
856
uni4->length = 2 * (uni4->string->uni_str_len);
915
878
str->buffer = TALLOC_ZERO_ARRAY(ctx, uint16, len + 1);
916
879
if (str->buffer == NULL) {
917
smb_panic("init_unistr2_w: malloc fail\n");
880
smb_panic("init_unistr2_w: talloc fail\n");
1095
1058
BOOL prs_unistr4(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4)
1097
1061
prs_debug(ps, depth, desc, "prs_unistr4");
1102
1066
if ( !prs_uint16("size", ps, depth, &uni4->size ))
1105
if ( !prs_pointer( desc, ps, depth, (void**)&uni4->string, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
1071
if ( !prs_pointer( desc, ps, depth, &ptr, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
1074
uni4->string = (UNISTR2 *)ptr;
1253
1221
/*******************************************************************
1254
Inits a DOM_RID2 structure.
1255
********************************************************************/
1257
void init_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx)
1261
rid2->rid_idx = idx;
1222
Inits a DOM_RID structure.
1223
********************************************************************/
1225
void init_dom_rid(DOM_RID *prid, uint32 rid, uint16 type, uint32 idx)
1229
prid->rid_idx = idx;
1232
/*******************************************************************
1233
Reads or writes a DOM_RID structure.
1234
********************************************************************/
1236
BOOL smb_io_dom_rid(const char *desc, DOM_RID *rid, prs_struct *ps, int depth)
1241
prs_debug(ps, depth, desc, "smb_io_dom_rid");
1247
if(!prs_uint16("type ", ps, depth, &rid->type))
1251
if(!prs_uint32("rid ", ps, depth, &rid->rid))
1253
if(!prs_uint32("rid_idx", ps, depth, &rid->rid_idx))
1264
1259
/*******************************************************************
1265
1260
Reads or writes a DOM_RID2 structure.
1266
1261
********************************************************************/
1268
BOOL smb_io_dom_rid2(const char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
1263
BOOL smb_io_dom_rid2(const char *desc, DOM_RID2 *rid, prs_struct *ps, int depth)
1273
1268
prs_debug(ps, depth, desc, "smb_io_dom_rid2");
1276
1271
if(!prs_align(ps))
1279
if(!prs_uint8("type ", ps, depth, &rid2->type))
1274
if(!prs_uint16("type ", ps, depth, &rid->type))
1281
1276
if(!prs_align(ps))
1283
if(!prs_uint32("rid ", ps, depth, &rid2->rid))
1285
if(!prs_uint32("rid_idx", ps, depth, &rid2->rid_idx))
1278
if(!prs_uint32("rid ", ps, depth, &rid->rid))
1280
if(!prs_uint32("rid_idx", ps, depth, &rid->rid_idx))
1282
if(!prs_uint32("unknown", ps, depth, &rid->unknown))
1291
1289
/*******************************************************************
1292
1290
creates a DOM_RID3 structure.
1293
1291
********************************************************************/
1368
1366
Inits or writes a DOM_CLNT_SRV structure.
1369
1367
********************************************************************/
1371
static BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *logcln, prs_struct *ps, int depth)
1369
BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *logcln, prs_struct *ps, int depth)
1373
1371
if (logcln == NULL)