From 97e6528f3111d065570af038bd583d0917ccdbd0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 31 Mar 2003 17:45:54 +0000 Subject: [PATCH] fix potential smbd crash when we fail to alloacte a policy handle for a printer open; CR 2102 (reviewed by jreilly) --- source/rpc_server/srv_spoolss_nt.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index 4cba304ea0e..f8a1ef0f1ef 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -4,8 +4,8 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Gerald Carter 2000-2001, + * Copyright (C) Jeremy Allison 2001-2002, + * Copyright (C) Gerald Carter 2000-2003, * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify @@ -499,13 +499,19 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 ZERO_STRUCTP(new_printer); - new_printer->notify.option=NULL; + if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { + SAFE_FREE(new_printer); + return False; + } /* Add to the internal list. */ DLIST_ADD(printers_list, new_printer); - if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { - SAFE_FREE(new_printer); + new_printer->notify.option=NULL; + + if ( !(new_printer->ctx = talloc_init_named("Printer Entry [0x%x]", (uint32)hnd)) ) { + DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); + close_printer_handle(p, hnd); return False; } -- 2.11.4.GIT