From 6fbd44c77a4512375fab9197e0a03af08d01b57c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 7 Mar 2002 04:22:16 +0000 Subject: Fixed a bunch of crash bugs for enumprinters at various info levels. (This used to be commit d9df00e2b1764619491900b7dbd7d5af34feed1b) --- source3/rpcclient/cmd_spoolss.c | 59 ++++++++++++++++++++++++----------------- source3/rpcclient/display_sec.c | 12 ++++----- 2 files changed, 41 insertions(+), 30 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 8d16ccdf54..a1e3d1f9ff 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -131,8 +131,11 @@ printer info level 0 display function ****************************************************************************/ static void display_print_info_0(PRINTER_INFO_0 *i0) { - fstring name = ""; - fstring servername = ""; + fstring name = ""; + fstring servername = ""; + + if (!i0) + return; if (i0->printername.buffer) rpcstr_pull(name, i0->printername.buffer, sizeof(name), 0, STR_TERMINATE); @@ -179,6 +182,8 @@ static void display_print_info_0(PRINTER_INFO_0 *i0) printf("\tunknown27:[0x%x]\n", i0->unknown27); printf("\tunknown28:[0x%x]\n", i0->unknown28); printf("\tunknown29:[0x%x]\n", i0->unknown29); + + printf("\n"); } /**************************************************************************** @@ -205,7 +210,9 @@ static void display_print_info_1(PRINTER_INFO_1 *i1) printf("\tflags:[0x%x]\n", i1->flags); printf("\tname:[%s]\n", name); printf("\tdescription:[%s]\n", desc); - printf("\tcomment:[%s]\n\n", comm); + printf("\tcomment:[%s]\n", comm); + + printf("\n"); } /**************************************************************************** @@ -278,7 +285,10 @@ static void display_print_info_2(PRINTER_INFO_2 *i2) printf("\tcjobs:[0x%x]\n", i2->cjobs); printf("\taverageppm:[0x%x]\n", i2->averageppm); - if (i2->secdesc) display_sec_desc(i2->secdesc); + if (i2->secdesc) + display_sec_desc(i2->secdesc); + + printf("\n"); } /**************************************************************************** @@ -289,6 +299,8 @@ static void display_print_info_3(PRINTER_INFO_3 *i3) printf("\tflags:[0x%x]\n", i3->flags); display_sec_desc(i3->secdesc); + + printf("\n"); } /* Enumerate printers */ @@ -330,27 +342,26 @@ static NTSTATUS cmd_spoolss_enum_printers(struct cli_state *cli, if (!num_printers) printf ("No Printers printers returned.\n"); - switch(info_level) { - case 0: - for (i=0; i < num_printers; i++) + for (i = 0; i < num_printers; i++) { + switch(info_level) { + case 0: display_print_info_0(&ctr.printers_0[i]); - break; - case 1: - for (i=0; i < num_printers; i++) + break; + case 1: display_print_info_1(&ctr.printers_1[i]); - break; - case 2: - for (i=0; i < num_printers; i++) + break; + case 2: display_print_info_2(&ctr.printers_2[i]); - break; - case 3: - for (i=0; i < num_printers; i++) + break; + case 3: display_print_info_3(&ctr.printers_3[i]); - break; - default: - printf("unknown info level %d\n", info_level); - break; + break; + default: + printf("unknown info level %d\n", info_level); + goto done; + } } + done: } return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; @@ -1451,9 +1462,9 @@ static NTSTATUS cmd_spoolss_deleteform(struct cli_state *cli, /* Enumerate forms */ -static NTSTATUS cmd_spoolss_enumforms(struct cli_state *cli, - TALLOC_CTX *mem_ctx, int argc, - char **argv) +static NTSTATUS cmd_spoolss_enum_forms(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) { POLICY_HND handle; WERROR werror; @@ -1543,7 +1554,7 @@ struct cmd_set spoolss_commands[] = { { "setform", cmd_spoolss_setform, PIPE_SPOOLSS, "Set form", "" }, { "getform", cmd_spoolss_getform, PIPE_SPOOLSS, "Get form", "" }, { "deleteform", cmd_spoolss_deleteform, PIPE_SPOOLSS, "Delete form", "" }, - { "enumforms", cmd_spoolss_enumforms, PIPE_SPOOLSS, "Enumerate forms", "" }, + { "enumforms", cmd_spoolss_enum_forms, PIPE_SPOOLSS, "Enumerate forms", "" }, { NULL } }; diff --git a/source3/rpcclient/display_sec.c b/source3/rpcclient/display_sec.c index 9d54fe2235..37043c5012 100644 --- a/source3/rpcclient/display_sec.c +++ b/source3/rpcclient/display_sec.c @@ -122,22 +122,22 @@ void display_sec_desc(SEC_DESC *sec) { fstring sid_str; - if (sec->off_sacl != 0) { - printf("S-ACL\n"); + if (sec->sacl) { + printf("SACL\n"); display_sec_acl(sec->sacl); } - if (sec->off_dacl != 0) { - printf("D-ACL\n"); + if (sec->dacl) { + printf("DACL\n"); display_sec_acl(sec->dacl); } - if (sec->off_owner_sid != 0) { + if (sec->owner_sid) { sid_to_string(sid_str, sec->owner_sid); printf("\tOwner SID:\t%s\n", sid_str); } - if (sec->off_grp_sid != 0) { + if (sec->grp_sid) { sid_to_string(sid_str, sec->grp_sid); printf("\tParent SID:\t%s\n", sid_str); } -- cgit