diff options
author | Jeremy Allison <jra@samba.org> | 2007-11-29 13:24:54 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-11-29 13:24:54 -0800 |
commit | d2cf97aeba14a4d336fb57b01f19bd5a08dcb003 (patch) | |
tree | 659f15d8011a1a110850c01e11078eae86d8bdad /source3/libsmb/cliprint.c | |
parent | 42c87fe6e6036a56b178183b034275321949050d (diff) | |
download | samba-d2cf97aeba14a4d336fb57b01f19bd5a08dcb003.tar.gz |
Remove the explicit TALLOC_CTX * from cli_struct.
Make us very explicit about how long a talloc ctx
should last.
Jeremy.
(This used to be commit ba9e2be2b5a59684e854609f9d82ea1633448c62)
Diffstat (limited to 'source3/libsmb/cliprint.c')
-rw-r--r-- | source3/libsmb/cliprint.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c index cab890b08bd..7fbdb97c016 100644 --- a/source3/libsmb/cliprint.c +++ b/source3/libsmb/cliprint.c @@ -1,18 +1,18 @@ -/* +/* Unix SMB/CIFS implementation. client print routines Copyright (C) Andrew Tridgell 1994-1998 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -21,13 +21,14 @@ /***************************************************************************** Convert a character pointer in a cli_call_api() response to a form we can use. - This function contains code to prevent core dumps if the server returns + This function contains code to prevent core dumps if the server returns invalid data. *****************************************************************************/ -static const char *fix_char_ptr(unsigned int datap, unsigned int converter, +static const char *fix_char_ptr(unsigned int datap, unsigned int converter, char *rdata, int rdrcnt) { - if (datap == 0) { /* turn NULL pointers into zero length strings */ + if (datap == 0) { + /* turn NULL pointers into zero length strings */ return ""; } else { unsigned int offset = datap - converter; @@ -42,41 +43,41 @@ static const char *fix_char_ptr(unsigned int datap, unsigned int converter, } } - /**************************************************************************** call fn() on each entry in a print queue ****************************************************************************/ -int cli_print_queue(struct cli_state *cli, + +int cli_print_queue(struct cli_state *cli, void (*fn)(struct print_job_info *)) { char *rparam = NULL; char *rdata = NULL; char *p; unsigned int rdrcnt, rprcnt; - pstring param; + char param[1024]; int result_code=0; int i = -1; - + memset(param,'\0',sizeof(param)); p = param; SSVAL(p,0,76); /* API function number 76 (DosPrintJobEnum) */ p += 2; - pstrcpy_base(p,"zWrLeh", param); /* parameter description? */ + safe_strcpy_base(p,"zWrLeh", param, sizeof(param)); /* parameter description? */ p = skip_string(param,sizeof(param),p); - pstrcpy_base(p,"WWzWWDDzz", param); /* returned data format */ + safe_strcpy_base(p,"WWzWWDDzz", param, sizeof(param)); /* returned data format */ p = skip_string(param,sizeof(param),p); - pstrcpy_base(p,cli->share, param); /* name of queue */ + safe_strcpy_base(p,cli->share, param, sizeof(param)); /* name of queue */ p = skip_string(param,sizeof(param),p); SSVAL(p,0,2); /* API function level 2, PRJINFO_2 data structure */ SSVAL(p,2,1000); /* size of bytes of returned data buffer */ p += 4; - pstrcpy_base(p,"", param); /* subformat */ + safe_strcpy_base(p,"", param,sizeof(param)); /* subformat */ p = skip_string(param,sizeof(param),p); DEBUG(4,("doing cli_print_queue for %s\n", cli->share)); - if (cli_api(cli, + if (cli_api(cli, param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */ NULL, 0, CLI_BUFFER_SIZE, /* data, length, maxlen */ &rparam, &rprcnt, /* return params, length */ @@ -87,21 +88,21 @@ int cli_print_queue(struct cli_state *cli, if (result_code == 0) { struct print_job_info job; - - p = rdata; + + p = rdata; for (i = 0; i < SVAL(rparam,4); ++i) { job.id = SVAL(p,0); job.priority = SVAL(p,2); fstrcpy(job.user, - fix_char_ptr(SVAL(p,4), converter, + fix_char_ptr(SVAL(p,4), converter, rdata, rdrcnt)); job.t = cli_make_unix_date3(cli, p + 12); job.size = IVAL(p,16); - fstrcpy(job.name,fix_char_ptr(SVAL(p,24), - converter, + fstrcpy(job.name,fix_char_ptr(SVAL(p,24), + converter, rdata, rdrcnt)); - fn(&job); + fn(&job); p += 28; } } @@ -117,6 +118,7 @@ int cli_print_queue(struct cli_state *cli, /**************************************************************************** cancel a print job ****************************************************************************/ + int cli_printjob_del(struct cli_state *cli, int job) { char *rparam = NULL; @@ -124,21 +126,21 @@ int cli_printjob_del(struct cli_state *cli, int job) char *p; unsigned int rdrcnt,rprcnt; int ret = -1; - pstring param; + char param[1024]; memset(param,'\0',sizeof(param)); p = param; SSVAL(p,0,81); /* DosPrintJobDel() */ p += 2; - pstrcpy_base(p,"W", param); + safe_strcpy_base(p,"W", param,sizeof(param)); p = skip_string(param,sizeof(param),p); - pstrcpy_base(p,"", param); + safe_strcpy_base(p,"", param,sizeof(param)); p = skip_string(param,sizeof(param),p); - SSVAL(p,0,job); + SSVAL(p,0,job); p += 2; - - if (cli_api(cli, + + if (cli_api(cli, param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */ NULL, 0, CLI_BUFFER_SIZE, /* data, length, maxlen */ &rparam, &rprcnt, /* return params, length */ @@ -178,7 +180,7 @@ int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_ accessmode |= 2; } else if ((flags & O_ACCMODE) == O_WRONLY) { accessmode |= 1; - } + } #if defined(O_SYNC) if ((flags & O_SYNC) == O_SYNC) { @@ -213,7 +215,7 @@ int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_ FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK); SSVAL(cli->outbuf,smb_vwv2,SVAL(cli->outbuf,smb_vwv2) | 6); } - + p = smb_buf(cli->outbuf); p += clistr_push(cli, p, fname, -1, STR_TERMINATE); @@ -256,5 +258,3 @@ bool cli_spl_close(struct cli_state *cli, int fnum) return !cli_is_error(cli); } - - |