$(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
$(DISPLAY_SEC_OBJ)
-TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
- $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
- $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
- $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
- $(DISPLAY_SEC_OBJ)
+#TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
+# $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
+# $(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
+# $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
+# $(DISPLAY_SEC_OBJ)
UTIL_REG_OBJ = lib/util_reg.o
UTIL_REG_API_OBJ = lib/util_reg_api.o
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS)
-bin/smbctool@EXEEXT@: $(BINARY_PREREQS) $(TOOL_OBJ) @BUILD_POPT@
- @echo Linking $@
- @$(CC) $(FLAGS) -o $@ $(TOOL_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) -Lbin -lsmbclient
+#bin/smbctool@EXEEXT@: $(BINARY_PREREQS) $(TOOL_OBJ) @BUILD_POPT@
+# @echo Linking $@
+# @$(CC) $(FLAGS) -o $@ $(TOOL_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) -Lbin -lsmbclient
bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@
@echo Linking $@
*dyn_BINDIR,
*dyn_SWATDIR;
-extern pstring dyn_CONFIGFILE;
-extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE;
-extern pstring dyn_LIBDIR;
-extern pstring dyn_CODEPAGEDIR;
+extern char dyn_CONFIGFILE[1024];
+extern char dyn_LOGFILEBASE[1024], dyn_LMHOSTSFILE[1024];
+extern char dyn_LIBDIR[1024];
+extern char dyn_CODEPAGEDIR[1024];
extern fstring dyn_SHLIBEXT;
-extern pstring dyn_LOCKDIR;
-extern pstring dyn_PIDDIR;
-extern pstring dyn_SMB_PASSWD_FILE;
-extern pstring dyn_PRIVATE_DIR;
+extern char dyn_LOCKDIR[1024];
+extern char dyn_PIDDIR[1024];
+extern char dyn_SMB_PASSWD_FILE[1024];
+extern char dyn_PRIVATE_DIR[1024];
char *dyn_STATEDIR(void);
char *dyn_CACHEDIR(void);
#define NGROUPS_MAX 32 /* Guess... */
#endif
-/* Our own pstrings and fstrings */
-#include "pstring.h"
+/* Our own fstrings */
+#define FSTRING_LEN 256
+typedef char fstring[FSTRING_LEN];
/* Lists, trees, caching, database... */
#include "xfile.h"
/* PRINTFLIKE2 */
void sys_adminlog(int priority, const char *format_str, ...) PRINTF_ATTRIBUTE(2,3);
-/* PRINTFLIKE2 */
-int pstr_sprintf(pstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
/* PRINTFLIKE2 */
int fstr_sprintf(fstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
typedef struct _client_referral {
uint32 proximity;
uint32 ttl;
- pstring dfspath;
+ char *dfspath;
} CLIENT_DFS_REFERRAL;
struct referral {
+++ /dev/null
-/*
- samba -- Unix SMB/CIFS implementation.
- Safe standardized string types
-
- Copyright (C) Andrew Tridgell 1992-2000
- Copyright (C) John H Terpstra 1996-2000
- Copyright (C) Luke Kenneth Casson Leighton 1996-2000
- Copyright (C) Paul Ashton 1998-2000
- Copyright (C) Martin Pool 2002
-
- 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/>.
-*/
-
-#ifndef _PSTRING
-
-#define PSTRING_LEN 1024
-#define FSTRING_LEN 256
-
-typedef char pstring[PSTRING_LEN];
-typedef char fstring[FSTRING_LEN];
-
-#define _PSTRING
-
-#endif /* ndef _PSTRING */
#define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *))
-#define push_pstring_base(dest, src, pstring_base) \
- (CHECK_STRING_SIZE(pstring_base, sizeof(pstring)) \
- ? __unsafe_string_function_usage_here_size_t__() \
- : push_ascii(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1, STR_TERMINATE))
-
#else /* HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS */
-#define push_pstring_base(dest, src, pstring_base) \
- push_ascii(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1, STR_TERMINATE)
-
#endif /* HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS */
#define safe_strcpy_base(dest, src, base, size) \
but the best we can do in C) and may tag with function name/number to
record the last 'clobber region' on that string */
-#define pstrcpy(d,s) safe_strcpy((d), (s),sizeof(pstring)-1)
-#define pstrcat(d,s) safe_strcat((d), (s),sizeof(pstring)-1)
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
#define nstrcpy(d,s) safe_strcpy((d), (s),sizeof(nstring)-1)
n = MIN(8,i%16);
print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " ));
n = (i%16) - n;
- if (n>0) print_asc(level,&buf[i-n],n);
- DEBUGADD(level,("\n"));
- }
+ if (n>0) print_asc(level,&buf[i-n],n);
+ DEBUGADD(level,("\n"));
+ }
}
void dump_data_pw(const char *msg, const uchar * data, size_t len)
char *tab_depth(int depth)
{
- static pstring spaces;
+ static fstring spaces;
size_t len = depth * 4;
- if (len > sizeof(pstring)-1) {
- len = sizeof(pstring)-1;
+ if (len > sizeof(fstring)-1) {
+ len = sizeof(fstring)-1;
}
memset(spaces, ' ', len);
int res = 0;
int c;
int i=0;
-
+
while(*s) {
c = *s;
res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
*
* @param name File to find, relative to LIBDIR.
*
- * @retval Pointer to a static #pstring containing the full path.
+ * @retval Pointer to a string containing the full path.
**/
char *lib_path(const char *name)
/**
Similar to string_sub2, but it will accept only allocated strings
and may realloc them so pay attention at what you pass on no
- pointers inside strings, no pstrings or const may be passed
+ pointers inside strings, no const may be passed
as string.
**/
s[j] = 0;
return s;
}
-/**
- Just a typesafety wrapper for snprintf into a pstring.
-**/
-
- int pstr_sprintf(pstring s, const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- va_start(ap, fmt);
- ret = vsnprintf(s, PSTRING_LEN, fmt, ap);
- va_end(ap);
- return ret;
-}
-
/**
Just a typesafety wrapper for snprintf into a fstring.
Get the dfs referral link.
********************************************************************/
-bool cli_dfs_get_referral(struct cli_state *cli,
+bool cli_dfs_get_referral(TALLOC_CTX *ctx,
+ struct cli_state *cli,
const char *path,
CLIENT_DFS_REFERRAL**refs,
size_t *num_refs,
unsigned int data_len = 0;
unsigned int param_len = 0;
uint16 setup = TRANSACT2_GET_DFS_REFERRAL;
- char param[1024+2];
+ char *param;
char *rparam=NULL, *rdata=NULL;
char *p;
+ char *endp;
size_t pathlen = 2*(strlen(path)+1);
uint16 num_referrals;
CLIENT_DFS_REFERRAL *referrals = NULL;
+ bool ret = false;
- memset(param, 0, sizeof(param));
+ *num_refs = 0;
+ *refs = NULL;
+
+ param = SMB_MALLOC(2+pathlen+2);
+ if (!param) {
+ return false;
+ }
SSVAL(param, 0, 0x03); /* max referral level */
p = ¶m[2];
- p += clistr_push(cli, p, path, MIN(pathlen, sizeof(param)-2),
- STR_TERMINATE);
+ p += clistr_push(cli, p, path, pathlen, STR_TERMINATE);
param_len = PTR_DIFF(p, param);
if (!cli_send_trans(cli, SMBtrans2,
- NULL, /* name */
- -1, 0, /* fid, flags */
- &setup, 1, 0, /* setup, length, max */
- param, param_len, 2, /* param, length, max */
- NULL, 0, cli->max_xmit /* data, length, max */
- )) {
- return false;
+ NULL, /* name */
+ -1, 0, /* fid, flags */
+ &setup, 1, 0, /* setup, length, max */
+ param, param_len, 2, /* param, length, max */
+ NULL, 0, cli->max_xmit /* data, length, max */
+ )) {
+ SAFE_FREE(param);
+ return false;
}
+ SAFE_FREE(param);
+
if (!cli_receive_trans(cli, SMBtrans2,
&rparam, ¶m_len,
&rdata, &data_len)) {
return false;
}
- *consumed = SVAL( rdata, 0 );
- num_referrals = SVAL( rdata, 2 );
+ if (data_len < 4) {
+ goto out;
+ }
- if ( num_referrals != 0 ) {
+ endp = rdata + data_len;
+
+ *consumed = SVAL(rdata, 0);
+ num_referrals = SVAL(rdata, 2);
+
+ if (num_referrals != 0) {
uint16 ref_version;
uint16 ref_size;
int i;
uint16 node_offset;
- referrals = SMB_XMALLOC_ARRAY( CLIENT_DFS_REFERRAL,
+ referrals = TALLOC_ARRAY(ctx, CLIENT_DFS_REFERRAL,
num_referrals);
+ if (!referrals) {
+ goto out;
+ }
/* start at the referrals array */
p = rdata+8;
- for ( i=0; i<num_referrals; i++ ) {
- ref_version = SVAL( p, 0 );
- ref_size = SVAL( p, 2 );
- node_offset = SVAL( p, 16 );
+ for (i=0; i<num_referrals && p < endp; i++) {
+ if (p + 18 > endp) {
+ goto out;
+ }
+ ref_version = SVAL(p, 0);
+ ref_size = SVAL(p, 2);
+ node_offset = SVAL(p, 16);
- if ( ref_version != 3 ) {
+ if (ref_version != 3) {
p += ref_size;
continue;
}
- referrals[i].proximity = SVAL( p, 8 );
- referrals[i].ttl = SVAL( p, 10 );
+ referrals[i].proximity = SVAL(p, 8);
+ referrals[i].ttl = SVAL(p, 10);
- clistr_pull( cli, referrals[i].dfspath, p+node_offset,
- sizeof(referrals[i].dfspath), -1,
+ if (p + node_offset > endp) {
+ goto out;
+ }
+ clistr_pull_talloc(ctx, cli, &referrals[i].dfspath,
+ p+node_offset,
STR_TERMINATE|STR_UNICODE );
+ if (!referrals[i].dfspath) {
+ goto out;
+ }
p += ref_size;
}
+ if (i < num_referrals) {
+ goto out;
+ }
}
+ ret = true;
+
*num_refs = num_referrals;
*refs = referrals;
+ out:
+
SAFE_FREE(rdata);
SAFE_FREE(rparam);
-
- return true;
+ return ret;
}
-
/********************************************************************
********************************************************************/
char **pp_targetpath)
{
CLIENT_DFS_REFERRAL *refs = NULL;
- size_t num_refs;
+ size_t num_refs = 0;
uint16 consumed;
struct cli_state *cli_ipc = NULL;
char *dfs_path = NULL;
return false;
}
- if (!cli_dfs_get_referral(cli_ipc, dfs_path, &refs,
+ if (!cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs,
&num_refs, &consumed) || !num_refs) {
return false;
}
/* Just store the first referral for now. */
+ if (!refs[0].dfspath) {
+ return false;
+ }
split_dfs_path(ctx, refs[0].dfspath, &server, &share, &extrapath );
- SAFE_FREE(refs);
if (!server || !share) {
return false;
char **pp_newshare )
{
CLIENT_DFS_REFERRAL *refs = NULL;
- size_t num_refs;
+ size_t num_refs = 0;
uint16 consumed;
char *fullpath = NULL;
bool res;
return false;
}
- res = cli_dfs_get_referral(cli, fullpath, &refs, &num_refs, &consumed);
+ res = cli_dfs_get_referral(ctx, cli, fullpath, &refs, &num_refs, &consumed);
if (!cli_tdis(cli)) {
- SAFE_FREE(refs);
return false;
}
cli->cnum = cnum;
if (!res || !num_refs) {
- SAFE_FREE(refs);
+ return false;
+ }
+
+ if (!refs[0].dfspath) {
return false;
}
split_dfs_path(ctx, refs[0].dfspath, pp_newserver,
pp_newshare, &newextrapath );
- SAFE_FREE(refs);
-
if (!pp_newserver || !pp_newshare) {
return false;
}
/* I'm trying really hard not to include anything from smb.h with the
result of some silly looking redeclaration of structures. */
-#ifndef _PSTRING
-#define _PSTRING
-#define PSTRING_LEN 1024
#define FSTRING_LEN 256
-typedef char pstring[PSTRING_LEN];
typedef char fstring[FSTRING_LEN];
-#endif
/* Some systems (SCO) treat UNIX domain sockets as FIFOs */