From aac823aca154c46264dd29510c89b8eafac361c8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Apr 2000 22:48:53 +0000 Subject: Modified interfaces and added checks around *all* *alloc calls so that errors are returned on memory allocation failure. Jeremy. (This used to be commit 9a118cd4a2b03146b341eeffb62144a2d29b574c) --- source3/rpc_server/srv_spoolss.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server/srv_spoolss.c') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index f23422d87a..8ae75eec6c 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -199,7 +199,8 @@ static BOOL api_spoolss_enumprinters(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n")); @@ -237,7 +238,8 @@ static BOOL api_spoolss_getprinter(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n")); @@ -275,7 +277,8 @@ static BOOL api_spoolss_getprinterdriver2(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n")); @@ -512,7 +515,8 @@ static BOOL api_spoolss_addjob(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_addjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n")); @@ -546,7 +550,8 @@ static BOOL api_spoolss_enumjobs(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n")); @@ -634,7 +639,8 @@ static BOOL api_spoolss_enumprinterdrivers(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n")); @@ -670,7 +676,8 @@ static BOOL api_spoolss_enumforms(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumforms("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n")); @@ -706,7 +713,8 @@ static BOOL api_spoolss_enumports(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_enumports("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n")); @@ -807,7 +815,8 @@ static BOOL api_spoolss_getprinterdriverdirectory(prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n")); @@ -952,7 +961,8 @@ static BOOL api_spoolss_enumprintprocessors(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n")); @@ -987,7 +997,8 @@ static BOOL api_spoolss_enumprintprocdatatypes(prs_struct *data, prs_struct *rda ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n")); @@ -1022,7 +1033,8 @@ static BOOL api_spoolss_enumprintmonitors(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n")); @@ -1054,7 +1066,8 @@ static BOOL api_spoolss_getjob(prs_struct *data, prs_struct *rdata) SPOOL_Q_GETJOB q_u; SPOOL_R_GETJOB r_u; - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n")); -- cgit