diff options
author | Jeremy Allison <jra@samba.org> | 2001-11-04 00:14:08 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-11-04 00:14:08 +0000 |
commit | 30be58a857e874fe439256726fbe182a2b578f11 (patch) | |
tree | 1fffcaaa6c0d0fdc76bb24c0ad8bcebb7758a2b5 /source3/libsmb | |
parent | f8e2baf39eb864481dd48f61404136b325cd73c2 (diff) | |
download | samba-30be58a857e874fe439256726fbe182a2b578f11.tar.gz samba-30be58a857e874fe439256726fbe182a2b578f11.tar.bz2 samba-30be58a857e874fe439256726fbe182a2b578f11.zip |
Got serious about const again.
REMOVED BZERO CALLS YET AGAIN !!! Why do these keep creeping back in....
They are *NOT* POSIX. I'm also thinking of removing strncpy as I'm sure
it's not being used correctly....
Jeremy.
(This used to be commit b1930abb35dee74f858a3f7190276c418af2322b)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/clidgram.c | 8 | ||||
-rw-r--r-- | source3/libsmb/clifile.c | 133 | ||||
-rw-r--r-- | source3/libsmb/clirap2.c | 53 | ||||
-rw-r--r-- | source3/libsmb/namequery.c | 4 |
4 files changed, 100 insertions, 98 deletions
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index fc1453dce1..e990739de5 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -41,7 +41,7 @@ int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot, char *ptr, *p2; char tmp[4]; - bzero((char *)&p, sizeof(p)); + memset((char *)&p, '\0', sizeof(p)); /* * Next, build the DGRAM ... @@ -183,7 +183,7 @@ int cli_get_backup_list(const char *myname, const char *send_to_name) /* Now, bind a local addr to it ... Try port 138 first ... */ - bzero((char *)&sock_out, sizeof(sock_out)); + memset((char *)&sock_out, '\0', sizeof(sock_out)); sock_out.sin_addr.s_addr = INADDR_ANY; sock_out.sin_port = htons(138); sock_out.sin_family = AF_INET; @@ -213,8 +213,8 @@ int cli_get_backup_list(const char *myname, const char *send_to_name) /* Now, build the request */ - bzero(cli_backup_list, sizeof(cli_backup_list)); - bzero(outbuf, sizeof(outbuf)); + memset(cli_backup_list, '\0', sizeof(cli_backup_list)); + memset(outbuf, '\0', sizeof(outbuf)); p = outbuf; diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index d9f8e19910..5c37255278 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -24,49 +24,47 @@ #include "includes.h" /**************************************************************************** -rename a file + Rename a file. ****************************************************************************/ -BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) + +BOOL cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst) { - char *p; + char *p; - memset(cli->outbuf,'\0',smb_size); - memset(cli->inbuf,'\0',smb_size); + memset(cli->outbuf,'\0',smb_size); + memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,1, 0, True); + set_message(cli->outbuf,1, 0, True); - CVAL(cli->outbuf,smb_com) = SMBmv; - SSVAL(cli->outbuf,smb_tid,cli->cnum); - cli_setup_packet(cli); + CVAL(cli->outbuf,smb_com) = SMBmv; + SSVAL(cli->outbuf,smb_tid,cli->cnum); + cli_setup_packet(cli); - SSVAL(cli->outbuf,smb_vwv0,aSYSTEM | aHIDDEN | aDIR); + SSVAL(cli->outbuf,smb_vwv0,aSYSTEM | aHIDDEN | aDIR); - p = smb_buf(cli->outbuf); - *p++ = 4; - p += clistr_push(cli, p, fname_src, -1, - STR_TERMINATE); - *p++ = 4; - p += clistr_push(cli, p, fname_dst, -1, - STR_TERMINATE); + p = smb_buf(cli->outbuf); + *p++ = 4; + p += clistr_push(cli, p, fname_src, -1, STR_TERMINATE); + *p++ = 4; + p += clistr_push(cli, p, fname_dst, -1, STR_TERMINATE); cli_setup_bcc(cli, p); - cli_send_smb(cli); - if (!cli_receive_smb(cli)) { - return False; - } + cli_send_smb(cli); + if (!cli_receive_smb(cli)) + return False; - if (cli_is_error(cli)) { - return False; - } + if (cli_is_error(cli)) + return False; - return True; + return True; } /**************************************************************************** -delete a file + Delete a file. ****************************************************************************/ -BOOL cli_unlink(struct cli_state *cli, char *fname) + +BOOL cli_unlink(struct cli_state *cli, const char *fname) { char *p; @@ -99,9 +97,10 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) } /**************************************************************************** -create a directory + Create a directory. ****************************************************************************/ -BOOL cli_mkdir(struct cli_state *cli, char *dname) + +BOOL cli_mkdir(struct cli_state *cli, const char *dname) { char *p; @@ -133,9 +132,10 @@ BOOL cli_mkdir(struct cli_state *cli, char *dname) } /**************************************************************************** -remove a directory + Remove a directory. ****************************************************************************/ -BOOL cli_rmdir(struct cli_state *cli, char *dname) + +BOOL cli_rmdir(struct cli_state *cli, const char *dname) { char *p; @@ -208,7 +208,7 @@ int cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag) } /**************************************************************************** - open a file - exposing the full horror of the NT API :-). + Open a file - exposing the full horror of the NT API :-). Used in smbtorture. ****************************************************************************/ @@ -265,7 +265,7 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname, uint32 DesiredA } /**************************************************************************** -open a file + Open a file. ****************************************************************************/ int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess) @@ -275,9 +275,10 @@ int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess } /**************************************************************************** -open a file -WARNING: if you open with O_WRONLY then getattrE won't work! + Open a file + WARNING: if you open with O_WRONLY then getattrE won't work! ****************************************************************************/ + int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode) { char *p; @@ -352,12 +353,10 @@ int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode return SVAL(cli->inbuf,smb_vwv2); } - - - /**************************************************************************** - close a file + Close a file. ****************************************************************************/ + BOOL cli_close(struct cli_state *cli, int fnum) { memset(cli->outbuf,'\0',smb_size); @@ -380,15 +379,15 @@ BOOL cli_close(struct cli_state *cli, int fnum) return !cli_is_error(cli); } - /**************************************************************************** - lock a file + Lock a file. ****************************************************************************/ + BOOL cli_lock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout, enum brl_type lock_type) { char *p; - int saved_timeout = cli->timeout; + int saved_timeout = cli->timeout; memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0', smb_size); @@ -417,10 +416,10 @@ BOOL cli_lock(struct cli_state *cli, int fnum, cli_send_smb(cli); - cli->timeout = (timeout == -1) ? 0x7FFFFFFF : (timeout + 2*1000); + cli->timeout = (timeout == -1) ? 0x7FFFFFFF : (timeout + 2*1000); if (!cli_receive_smb(cli)) { - cli->timeout = saved_timeout; + cli->timeout = saved_timeout; return False; } @@ -434,8 +433,9 @@ BOOL cli_lock(struct cli_state *cli, int fnum, } /**************************************************************************** - unlock a file + Unlock a file. ****************************************************************************/ + BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len) { char *p; @@ -474,10 +474,10 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len) return True; } - /**************************************************************************** - lock a file with 64 bit offsets + Lock a file with 64 bit offsets. ****************************************************************************/ + BOOL cli_lock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type) { @@ -534,8 +534,9 @@ BOOL cli_lock64(struct cli_state *cli, int fnum, } /**************************************************************************** - unlock a file with 64 bit offsets + Unlock a file with 64 bit offsets. ****************************************************************************/ + BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len) { char *p; @@ -578,13 +579,10 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_ return True; } - - - - /**************************************************************************** -do a SMBgetattrE call + Do a SMBgetattrE call. ****************************************************************************/ + BOOL cli_getattrE(struct cli_state *cli, int fd, uint16 *attr, size_t *size, time_t *c_time, time_t *a_time, time_t *m_time) @@ -632,11 +630,11 @@ BOOL cli_getattrE(struct cli_state *cli, int fd, return True; } - /**************************************************************************** -do a SMBgetatr call + Do a SMBgetatr call ****************************************************************************/ -BOOL cli_getatr(struct cli_state *cli, char *fname, + +BOOL cli_getatr(struct cli_state *cli, const char *fname, uint16 *attr, size_t *size, time_t *t) { char *p; @@ -681,11 +679,11 @@ BOOL cli_getatr(struct cli_state *cli, char *fname, return True; } - /**************************************************************************** -do a SMBsetatr call + Do a SMBsetatr call. ****************************************************************************/ -BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t) + +BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 attr, time_t t) { char *p; @@ -720,11 +718,11 @@ BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t) return True; } - /**************************************************************************** -check for existance of a dir + Check for existance of a dir. ****************************************************************************/ -BOOL cli_chkpath(struct cli_state *cli, char *path) + +BOOL cli_chkpath(struct cli_state *cli, const char *path) { pstring path2; char *p; @@ -754,11 +752,10 @@ BOOL cli_chkpath(struct cli_state *cli, char *path) return True; } - - /**************************************************************************** -query disk space + Query disk space. ****************************************************************************/ + BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail) { memset(cli->outbuf,'\0',smb_size); @@ -779,11 +776,11 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail) return True; } - /**************************************************************************** -create and open a temporary file + Create and open a temporary file. ****************************************************************************/ -int cli_ctemp(struct cli_state *cli, char *path, char **tmp_path) + +int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path) { int len; char *p; diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c index f19ec3e758..2fde0c70e5 100644 --- a/source3/libsmb/clirap2.c +++ b/source3/libsmb/clirap2.c @@ -149,7 +149,7 @@ static char *make_header(char *param, uint16 apinum, char *reqfmt, char *datafmt /**************************************************************************** call a NetGroupDelete - delete user group from remote server ****************************************************************************/ -int cli_NetGroupDelete(struct cli_state *cli, char * group_name ) +int cli_NetGroupDelete(struct cli_state *cli, const char *group_name ) { char *rparam = NULL; char *rdata = NULL; @@ -277,7 +277,7 @@ int cli_RNetGroupEnum(struct cli_state *cli, void (*fn)(const char *, const char int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0', sizeof(param)); p = make_header(param, RAP_WGroupEnum, RAP_NetGroupEnum_REQ, RAP_GROUP_INFO_L1); PUTWORD(p,1); /* Info level 1 */ /* add level 0 */ @@ -328,7 +328,7 @@ int cli_RNetGroupEnum(struct cli_state *cli, void (*fn)(const char *, const char return res; } -int cli_NetGroupDelUser(struct cli_state * cli, char * group_name, char * user_name) +int cli_NetGroupDelUser(struct cli_state * cli, const char *group_name, const char *user_name) { char *rparam = NULL; char *rdata = NULL; @@ -386,7 +386,7 @@ int cli_NetGroupDelUser(struct cli_state * cli, char * group_name, char * user_n return res; } -int cli_NetGroupAddUser(struct cli_state * cli, char * group_name, char * user_name) +int cli_NetGroupAddUser(struct cli_state * cli, const char *group_name, const char *user_name) { char *rparam = NULL; char *rdata = NULL; @@ -442,7 +442,7 @@ int cli_NetGroupAddUser(struct cli_state * cli, char * group_name, char * user_n } -int cli_NetGroupGetUsers(struct cli_state * cli, char * group_name, void (*fn)(const char *, void *), void *state ) +int cli_NetGroupGetUsers(struct cli_state * cli, const char *group_name, void (*fn)(const char *, void *), void *state ) { char *rparam = NULL; char *rdata = NULL; @@ -497,7 +497,7 @@ int cli_NetGroupGetUsers(struct cli_state * cli, char * group_name, void (*fn)(c return res; } -int cli_NetUserGetGroups(struct cli_state * cli, char * user_name, void (*fn)(const char *, void *), void *state ) +int cli_NetUserGetGroups(struct cli_state * cli, const char *user_name, void (*fn)(const char *, void *), void *state ) { char *rparam = NULL; char *rdata = NULL; @@ -556,7 +556,7 @@ int cli_NetUserGetGroups(struct cli_state * cli, char * user_name, void (*fn)(co /**************************************************************************** call a NetUserDelete - delete user from remote server ****************************************************************************/ -int cli_NetUserDelete(struct cli_state *cli, char * user_name ) +int cli_NetUserDelete(struct cli_state *cli, const char * user_name ) { char *rparam = NULL; char *rdata = NULL; @@ -647,7 +647,7 @@ int cli_NetUserAdd(struct cli_state *cli, RAP_USER_INFO_1 * userinfo ) PUTWORD(p, 0); /* password length */ p = data; - bzero(data, soffset); + memset(data, '\0', soffset); PUTSTRINGF(p, userinfo->user_name, RAP_USERNAME_LEN); PUTBYTE(p, 0); /* pad byte 0 */ @@ -707,7 +707,7 @@ int cli_RNetUserEnum(struct cli_state *cli, void (*fn)(const char *, const char int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0', sizeof(param)); p = make_header(param, RAP_WUserEnum, RAP_NetUserEnum_REQ, RAP_USER_INFO_L1); PUTWORD(p,1); /* Info level 1 */ @@ -984,7 +984,7 @@ int cli_NetShareAdd(struct cli_state *cli, RAP_SHARE_INFO_2 * sinfo ) + DWORDSIZE /* share path */ + RAP_SPASSWD_LEN + 1; /* share password + pad */ - bzero(param,sizeof(param)); + memset(param,'\0',sizeof(param)); /* now send a SMBtrans command with api RNetShareAdd */ p = make_header(param, RAP_WshareAdd, RAP_WShareAdd_REQ, RAP_SHARE_INFO_L2); @@ -1031,7 +1031,7 @@ int cli_NetShareAdd(struct cli_state *cli, RAP_SHARE_INFO_2 * sinfo ) /**************************************************************************** call a NetShareDelete - unshare exported directory on remote server ****************************************************************************/ -int cli_NetShareDelete(struct cli_state *cli, char * share_name ) +int cli_NetShareDelete(struct cli_state *cli, const char * share_name ) { char *rparam = NULL; char *rdata = NULL; @@ -1424,7 +1424,9 @@ BOOL cli_NetWkstaUserLogoff(struct cli_state *cli,char *user, char *workstation) return (cli->rap_error == 0); } -int cli_NetPrintQEnum(struct cli_state *cli, void (*qfn)(char*,uint16,uint16,uint16,char*,char*,char*,char*,char*,uint16,uint16),void (*jfn)(uint16,char*,char*,char*,char*,uint16,uint16,char*,uint,uint,char*)) +int cli_NetPrintQEnum(struct cli_state *cli, + void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16), + void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,uint,uint,const char*)) { char param[WORDSIZE /* api number */ +sizeof(RAP_NetPrintQEnum_REQ) /* req string */ @@ -1439,7 +1441,7 @@ int cli_NetPrintQEnum(struct cli_state *cli, void (*qfn)(char*,uint16,uint16,ui int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0',sizeof(param)); p = make_header(param, RAP_WPrintQEnum, RAP_NetPrintQEnum_REQ, RAP_PRINTQ_INFO_L2); PUTWORD(p,2); /* Info level 2 */ @@ -1525,7 +1527,9 @@ int cli_NetPrintQEnum(struct cli_state *cli, void (*qfn)(char*,uint16,uint16,ui return res; } -int cli_NetPrintQGetInfo(struct cli_state *cli, char *printer, void (*qfn)(char*,uint16,uint16,uint16,char*,char*,char*,char*,char*,uint16,uint16),void (*jfn)(uint16,char*,char*,char*,char*,uint16,uint16,char*,uint,uint,char*)) +int cli_NetPrintQGetInfo(struct cli_state *cli, const char *printer, + void (*qfn)(const char*,uint16,uint16,uint16,const char*,const char*,const char*,const char*,const char*,uint16,uint16), + void (*jfn)(uint16,const char*,const char*,const char*,const char*,uint16,uint16,const char*,uint,uint,const char*)) { char param[WORDSIZE /* api number */ +sizeof(RAP_NetPrintQGetInfo_REQ) /* req string */ @@ -1541,7 +1545,7 @@ int cli_NetPrintQGetInfo(struct cli_state *cli, char *printer, void (*qfn)(char* int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0',sizeof(param)); p = make_header(param, RAP_WPrintQGetInfo, RAP_NetPrintQGetInfo_REQ, RAP_PRINTQ_INFO_L2); PUTSTRING(p, printer, RAP_SHARENAME_LEN-1); @@ -1640,7 +1644,7 @@ int cli_RNetServiceEnum(struct cli_state *cli, void (*fn)(const char *, const ch int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0', sizeof(param)); p = make_header(param, RAP_WServiceEnum, RAP_NetServiceEnum_REQ, RAP_SERVICE_INFO_L2); PUTWORD(p,2); /* Info level 2 */ @@ -1708,7 +1712,7 @@ int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16, int rprcnt, rdrcnt; int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0', sizeof(param)); p = make_header(param, RAP_WsessionEnum, RAP_NetSessionEnum_REQ, RAP_SESSION_INFO_L2); PUTWORD(p,2); /* Info level 2 */ @@ -1767,9 +1771,10 @@ int cli_NetSessionEnum(struct cli_state *cli, void (*fn)(char *, char *, uint16, } /**************************************************************************** -call a NetSessionGetInfo - get information about other session to an SMB server + Call a NetSessionGetInfo - get information about other session to an SMB server. ****************************************************************************/ -int cli_NetSessionGetInfo(struct cli_state *cli, char *workstation, void (*fn)(char *, char *, uint16, uint16, uint16, uint, uint, uint, char *)) + +int cli_NetSessionGetInfo(struct cli_state *cli, const char *workstation, void (*fn)(const char *, const char *, uint16, uint16, uint16, uint, uint, uint, const char *)) { char param[WORDSIZE /* api number */ +sizeof(RAP_NetSessionGetInfo_REQ) /* req string */ @@ -1784,7 +1789,7 @@ int cli_NetSessionGetInfo(struct cli_state *cli, char *workstation, void (*fn)(c int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0', sizeof(param)); p = make_header(param, RAP_WsessionGetInfo, RAP_NetSessionGetInfo_REQ, RAP_SESSION_INFO_L2); PUTSTRING(p, workstation, RAP_MACHNAME_LEN-1); @@ -1844,7 +1849,7 @@ int cli_NetSessionGetInfo(struct cli_state *cli, char *workstation, void (*fn)(c /**************************************************************************** call a NetSessionDel - close a session to an SMB server ****************************************************************************/ -int cli_NetSessionDel(struct cli_state *cli, char *workstation) +int cli_NetSessionDel(struct cli_state *cli, const char *workstation) { char param[WORDSIZE /* api number */ +sizeof(RAP_NetSessionDel_REQ) /* req string */ @@ -1857,7 +1862,7 @@ int cli_NetSessionDel(struct cli_state *cli, char *workstation) int rprcnt, rdrcnt; int res; - bzero(param, sizeof(param)); + memset(param, '\0', sizeof(param)); p = make_header(param, RAP_WsessionDel, RAP_NetSessionDel_REQ, NULL); PUTSTRING(p, workstation, RAP_MACHNAME_LEN-1); PUTWORD(p,0); /* reserved word of 0 */ @@ -1888,7 +1893,7 @@ int cli_NetSessionDel(struct cli_state *cli, char *workstation) } -int cli_NetConnectionEnum(struct cli_state *cli, char *qualifier, void (*fn)(uint16 conid, uint16 contype, uint16 numopens, uint16 numusers, uint32 contime, char *username, char *netname)) +int cli_NetConnectionEnum(struct cli_state *cli, const char *qualifier, void (*fn)(uint16 conid, uint16 contype, uint16 numopens, uint16 numusers, uint32 contime, const char *username, const char *netname)) { char param[WORDSIZE /* api number */ +sizeof(RAP_NetConnectionEnum_REQ) /* req string */ @@ -1902,7 +1907,7 @@ int cli_NetConnectionEnum(struct cli_state *cli, char *qualifier, void (*fn)(uin int rprcnt, rdrcnt; int res = -1; - bzero(param, sizeof(param)); + memset(param, '\0', sizeof(param)); p = make_header(param, RAP_WconnectionEnum, RAP_NetConnectionEnum_REQ, RAP_CONNECTION_INFO_L1); PUTSTRING(p, qualifier, RAP_MACHNAME_LEN-1);/* Workstation name */ diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 0dbf4b4564..1e284aab19 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -205,7 +205,7 @@ BOOL name_register(int fd, const char *name, int name_type, register_ip.s_addr = name_ip.s_addr; /* Fix this ... */ - bzero((char *)&p, sizeof(p)); + memset((char *)&p, '\0', sizeof(p)); *count = 0; @@ -237,7 +237,7 @@ BOOL name_register(int fd, const char *name, int name_type, } - bzero((char *)nmb->additional, sizeof(struct res_rec)); + memset((char *)nmb->additional, '\0', sizeof(struct res_rec)); nmb->additional->rr_name = nmb->question.question_name; nmb->additional->rr_type = RR_TYPE_NB; |