From b33dcc30c3fd812a19692e474680a87149117380 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Mon, 27 Oct 2014 20:13:59 +0100 Subject: [PATCH] spoolss: fix handling of bad EnumJobs levels Currently Samba is inconsistent when returning WERR_UNKNOWN_LEVEL errors for spoolss EnumJobs requests - if no print jobs are present, then WERR_OK will be returned, regardless of whether the EnumJobs level is supported or not. This change fixes this behaviour, by catching invalid or unsupported levels prior to the no-jobs response fast-path. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10898 Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue Oct 28 03:05:35 CET 2014 on sn-devel-104 (cherry picked from commit d4f233a746d89e13aae78008b499c71b695ff882) --- source3/rpc_server/spoolss/srv_spoolss_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 44497a6..f0ae9fa 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -7323,6 +7323,11 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p, return WERR_INVALID_PARAM; } + if ((r->in.level != 1) && (r->in.level != 2) && (r->in.level != 3)) { + DEBUG(4, ("EnumJobs level %d not supported\n", r->in.level)); + return WERR_UNKNOWN_LEVEL; + } + DEBUG(4,("_spoolss_EnumJobs\n")); *r->out.needed = 0; @@ -7368,7 +7373,7 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p, pinfo2, r->out.info, r->out.count); break; default: - result = WERR_UNKNOWN_LEVEL; + SMB_ASSERT(false); /* level checked on entry */ break; } -- 1.8.4.5