1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

updating reg_value_info() parsing code to take BUFFER2 instead of just

a char*.  now copes with multiple types.
This commit is contained in:
Luke Leighton
-
parent 98ddeaf442
commit 3df7c903c5
6 changed files with 55 additions and 46 deletions

View File

@ -1874,7 +1874,7 @@ BOOL do_reg_query_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
BOOL do_reg_unknown_1a(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 *unk);
BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
const char* val_name,
char *type);
uint32 *type, BUFFER2 *buf);
BOOL do_reg_set_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
uint32 sec_buf_size, SEC_DESC *sec_buf);
BOOL do_reg_get_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
@ -2499,7 +2499,7 @@ BOOL make_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, const char *val_name,
uint8 major, uint8 minor);
BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth);
BOOL make_reg_r_info(REG_R_INFO *r_r,
uint32 type, char *buf,
uint32 *type, BUFFER2 *buf,
uint32 status);
BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth);
BOOL make_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,

View File

@ -442,10 +442,10 @@ typedef struct q_reg_info_info
typedef struct r_reg_info_info
{
uint32 ptr_type; /* buffer pointer */
uint32 type; /* 0x1 - info level? */
uint32 *type; /* 0x1 - info level? */
uint32 ptr_uni_type; /* pointer to o/s type */
BUFFER2 uni_type; /* unicode string o/s type - "LanmanNT" */
BUFFER2 *uni_type; /* unicode string o/s type - "LanmanNT" */
uint32 ptr_max_len; /* pointer to unknown_0 */
uint32 buf_max_len; /* 0x12 */

View File

@ -451,7 +451,7 @@ do a REG Query Info
****************************************************************************/
BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
const char* val_name,
char *type)
uint32 *type, BUFFER2 *buffer)
{
prs_struct rbuf;
prs_struct buf;
@ -480,6 +480,9 @@ BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
ZERO_STRUCT(r_o);
r_o.type = type;
r_o.uni_type = buffer;
reg_io_r_info("", &r_o, &rbuf, 0);
p = rbuf.offset != 0;
@ -493,8 +496,6 @@ BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
if (p)
{
valid_query = True;
unibuf_to_ascii(type, (const char*)r_o.uni_type.buffer,
MIN(r_o.uni_type.buf_len, sizeof(fstring)-1));
}
}

View File

@ -896,27 +896,31 @@ BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
creates a structure.
********************************************************************/
BOOL make_reg_r_info(REG_R_INFO *r_r,
uint32 type, char *buf,
uint32 *type, BUFFER2 *buf,
uint32 status)
{
int len;
if (r_r == NULL) return False;
if (r_r == NULL || buf == NULL) return False;
len = strlen(buf);
r_r->ptr_type = type;
r_r->ptr_type = type != NULL ? 1 : 0;
r_r->type = type;
r_r->ptr_uni_type = 1;
make_buffer2(&(r_r->uni_type), buf, len);
r_r->ptr_uni_type = buf != NULL ? 1 : 0;
r_r->uni_type = buf;
r_r->ptr_max_len = 1;
r_r->buf_max_len = r_r->uni_type.buf_max_len;
r_r->ptr_len = 1;
r_r->buf_len = r_r->uni_type.buf_len;
if (buf != NULL)
{
r_r->ptr_max_len = 1;
r_r->buf_max_len = r_r->uni_type->buf_max_len;
r_r->ptr_len = 1;
r_r->buf_len = r_r->uni_type->buf_len;
}
else
{
r_r->ptr_max_len = 0;
r_r->ptr_len = 0;
}
r_r->status = status;
return True;
@ -937,11 +941,11 @@ BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type));
if (r_r->ptr_type != 0)
{
prs_uint32("type", ps, depth, &(r_r->type));
prs_uint32("type", ps, depth, r_r->type);
}
prs_uint32("ptr_uni_type", ps, depth, &(r_r->ptr_uni_type));
smb_io_buffer2("uni_type", &(r_r->uni_type), r_r->ptr_uni_type, ps, depth);
smb_io_buffer2("uni_type", r_r->uni_type, r_r->ptr_uni_type, ps, depth);
prs_align(ps);
prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len));

View File

@ -187,6 +187,8 @@ static void reg_reply_info(REG_Q_INFO *q_u,
uint32 status = 0;
REG_R_INFO r_u;
uint32 type = 1;
BUFFER2 buf;
DEBUG(5,("reg_info: %d\n", __LINE__));
@ -197,7 +199,9 @@ static void reg_reply_info(REG_Q_INFO *q_u,
if (status == 0)
{
make_reg_r_info(&r_u, 1, "LanmanNT", status);
char *key = "LanmanNT";
make_buffer2(&buf, key, strlen(key));
make_reg_r_info(&r_u, &type, &buf, status);
}

View File

@ -97,24 +97,6 @@ static void reg_display_key(int val, const char *full_keyname, int num)
}
}
static void reg_display_key_info(const char *full_name,
const char *name, time_t key_mod_time)
{
display_reg_key_info(out_hnd, ACTION_HEADER , name, key_mod_time);
display_reg_key_info(out_hnd, ACTION_ENUMERATE, name, key_mod_time);
display_reg_key_info(out_hnd, ACTION_FOOTER , name, key_mod_time);
}
static void reg_display_val_info(const char *full_name,
const char* name,
uint32 type,
const BUFFER2 *const value)
{
display_reg_value_info(out_hnd, ACTION_HEADER , name, type, value);
display_reg_value_info(out_hnd, ACTION_ENUMERATE, name, type, value);
display_reg_value_info(out_hnd, ACTION_FOOTER , name, type, value);
}
/****************************************************************************
nt registry enum
@ -283,6 +265,24 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
return res1;
}
static void reg_display_key_info(const char *full_name,
const char *name, time_t key_mod_time)
{
display_reg_key_info(out_hnd, ACTION_HEADER , name, key_mod_time);
display_reg_key_info(out_hnd, ACTION_ENUMERATE, name, key_mod_time);
display_reg_key_info(out_hnd, ACTION_FOOTER , name, key_mod_time);
}
static void reg_display_val_info(const char *full_name,
const char* name,
uint32 type,
const BUFFER2 *const value)
{
display_reg_value_info(out_hnd, ACTION_HEADER , name, type, value);
display_reg_value_info(out_hnd, ACTION_ENUMERATE, name, type, value);
display_reg_value_info(out_hnd, ACTION_FOOTER , name, type, value);
}
/****************************************************************************
nt registry enum
****************************************************************************/
@ -325,9 +325,9 @@ void cmd_reg_query_info(struct client_info *info)
* query value info
*/
fstring type;
BUFFER2 buf;
uint32 type;
type[0] = 0;
DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
@ -364,11 +364,11 @@ void cmd_reg_query_info(struct client_info *info)
/* query it */
res1 = res1 ? do_reg_query_info(smb_cli, fnum, &key_pol,
val_name, type) : False;
val_name, &type, &buf) : False;
if (res1)
{
report(out_hnd, "type:\t%s\n", type);
reg_display_val_info(full_keyname, val_name, type, &buf);
}
/* close the handles */