summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-12-17 16:54:42 +0100
committerAndreas Schneider <asn@cryptomilk.org>2014-12-19 15:40:43 +0100
commita11e97b79645ff0d9e7d20f5318a979194a858fe (patch)
tree832c4a7ac122390551fa544977c9bea76bc42b95
parentc9fccb5018f9a19bb654b9ad79aa716e37a274d6 (diff)
downloadsamba-a11e97b79645ff0d9e7d20f5318a979194a858fe.tar.gz
spoolss: clear PrinterInfo on GetPrinter error
If an error is returned without zeroing a pre-allocated @info pointer, then marshalling of the response will fail. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10984 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index c34b04de898..115af2d6869 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -4778,17 +4778,20 @@ WERROR _spoolss_GetPrinter(struct pipes_struct *p,
/* that's an [in out] buffer */
if (!r->in.buffer && (r->in.offered != 0)) {
- return WERR_INVALID_PARAM;
+ result = WERR_INVALID_PARAM;
+ goto err_info_free;
}
*r->out.needed = 0;
if (Printer == NULL) {
- return WERR_BADFID;
+ result = WERR_BADFID;
+ goto err_info_free;
}
if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
- return WERR_BADFID;
+ result = WERR_BADFID;
+ goto err_info_free;
}
result = winreg_get_printer_internal(p->mem_ctx,
@@ -4797,7 +4800,7 @@ WERROR _spoolss_GetPrinter(struct pipes_struct *p,
lp_const_servicename(snum),
&info2);
if (!W_ERROR_IS_OK(result)) {
- goto out;
+ goto err_info_free;
}
switch (r->in.level) {
@@ -4857,12 +4860,10 @@ WERROR _spoolss_GetPrinter(struct pipes_struct *p,
}
TALLOC_FREE(info2);
- out:
if (!W_ERROR_IS_OK(result)) {
DEBUG(0, ("_spoolss_GetPrinter: failed to construct printer info level %d - %s\n",
r->in.level, win_errstr(result)));
- TALLOC_FREE(r->out.info);
- return result;
+ goto err_info_free;
}
*r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_PrinterInfo,
@@ -4870,6 +4871,10 @@ WERROR _spoolss_GetPrinter(struct pipes_struct *p,
r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
+
+err_info_free:
+ TALLOC_FREE(r->out.info);
+ return result;
}
/********************************************************************