summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-10 22:31:34 -0800
committerJeremy Allison <jra@samba.org>2007-11-10 22:31:34 -0800
commit2b3c44e4fb980335c22abcc07a88f32b13e5918f (patch)
tree47eedc95e86696e59a7ce650b5a3eb03a8a1be9e /source3
parent41ae2a0a17d3f67252e81a6db730f87ce26fb939 (diff)
downloadsamba-2b3c44e4fb980335c22abcc07a88f32b13e5918f.tar.gz
samba-2b3c44e4fb980335c22abcc07a88f32b13e5918f.tar.bz2
samba-2b3c44e4fb980335c22abcc07a88f32b13e5918f.zip
Always define PATH_MAX. Makes code simpler (removes
a bunch of #defines). Remove pstring from msdfs.c. Jeremy. (This used to be commit e203ba22275320808bc11b17361ad1f2d5b0b897)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/replace/replace.h4
-rw-r--r--source3/lib/system.c4
-rw-r--r--source3/lib/util_unistr.c11
-rw-r--r--source3/smbd/msdfs.c62
-rw-r--r--source3/smbd/service.c4
-rw-r--r--source3/smbd/vfs.c12
6 files changed, 55 insertions, 42 deletions
diff --git a/source3/lib/replace/replace.h b/source3/lib/replace/replace.h
index 973c68ee14..36a355f0a9 100644
--- a/source3/lib/replace/replace.h
+++ b/source3/lib/replace/replace.h
@@ -536,4 +536,8 @@ typedef int bool;
#define QSORT_CAST (int (*)(const void *, const void *))
#endif
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
#endif /* _LIBREPLACE_REPLACE_H */
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 321bca83bb..7338ea7750 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -573,12 +573,8 @@ char *sys_getwd(char *s)
{
char *wd;
#ifdef HAVE_GETCWD
-#ifdef PATH_MAX
wd = (char *)getcwd(s, PATH_MAX);
#else
- wd = (char *)getcwd(s, sizeof (pstring));
-#endif
-#else
wd = (char *)getwd(s);
#endif
return wd;
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index e9e2c33fb3..c4569e102e 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -350,11 +350,20 @@ char *rpcstr_pull_unistr2_talloc(TALLOC_CTX *mem_ctx, const UNISTR2 *src)
/* Converts a string from internal samba format to unicode
*/
-int rpcstr_push(void* dest, const char *src, size_t dest_len, int flags)
+int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags)
{
return push_ucs2(NULL, dest, src, dest_len, flags|STR_UNICODE|STR_NOALIGN);
}
+/* Converts a string from internal samba format to unicode. Always terminates.
+ * Actually just a wrapper round push_ucs2_talloc().
+ */
+
+int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
+{
+ return push_ucs2_talloc(ctx, dest, src);
+}
+
/*******************************************************************
Convert a (little-endian) UNISTR2 structure to an ASCII string.
********************************************************************/
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index cca1e0a428..98a41e4ec3 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -196,16 +196,26 @@ static NTSTATUS parse_dfs_path(const char *pathname,
Note this CHANGES CWD !!!! JRA.
*********************************************************/
-static NTSTATUS create_conn_struct(connection_struct *conn,
+static NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
+ connection_struct *conn,
int snum,
const char *path)
{
- pstring connpath;
+ char *connpath;
ZERO_STRUCTP(conn);
- pstrcpy(connpath, path);
- pstring_sub(connpath , "%S", lp_servicename(snum));
+ connpath = talloc_strdup(ctx, path);
+ if (!connpath) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ connpath = talloc_string_sub(ctx,
+ connpath,
+ "%S",
+ lp_servicename(snum));
+ if (!connpath) {
+ return NT_STATUS_NO_MEMORY;
+ }
/* needed for smbd_vfs_init() */
@@ -844,7 +854,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- status = create_conn_struct(conn, snum, lp_pathname(snum));
+ status = create_conn_struct(ctx, conn, snum, lp_pathname(snum));
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(pdp);
return status;
@@ -888,7 +898,7 @@ static int setup_ver2_dfs_referral(const char *pathname,
{
char* pdata = *ppdata;
- unsigned char uni_requestedpath[sizeof(pstring)];
+ smb_ucs2_t *uni_requestedpath = NULL;
int uni_reqpathoffset1,uni_reqpathoffset2;
int uni_curroffset;
int requestedpathlen=0;
@@ -898,12 +908,15 @@ static int setup_ver2_dfs_referral(const char *pathname,
DEBUG(10,("Setting up version2 referral\nRequested path:\n"));
- requestedpathlen = rpcstr_push(uni_requestedpath,
- pathname, sizeof(pstring),
- STR_TERMINATE);
+ requestedpathlen = rpcstr_push_talloc(talloc_tos(),
+ &uni_requestedpath, pathname);
+ if (uni_requestedpath == NULL || requestedpathlen == 0) {
+ return -1;
+ }
if (DEBUGLVL(10)) {
- dump_data(0, uni_requestedpath,requestedpathlen);
+ dump_data(0, (unsigned char *)uni_requestedpath,
+ requestedpathlen);
}
DEBUG(10,("ref count = %u\n",junction->referral_count));
@@ -976,8 +989,10 @@ static int setup_ver2_dfs_referral(const char *pathname,
SSVAL(pdata,offset+16,uni_reqpathoffset1-offset);
SSVAL(pdata,offset+18,uni_reqpathoffset2-offset);
/* copy referred path into current offset */
- unilen = rpcstr_push(pdata+uni_curroffset, ref->alternate_path,
- sizeof(pstring), STR_UNICODE);
+ unilen = rpcstr_push(pdata+uni_curroffset,
+ ref->alternate_path,
+ reply_size - uni_curroffset,
+ STR_UNICODE);
SSVAL(pdata,offset+20,uni_curroffset-offset);
@@ -997,7 +1012,7 @@ static int setup_ver3_dfs_referral(const char *pathname,
{
char *pdata = *ppdata;
- unsigned char uni_reqpath[sizeof(pstring)];
+ smb_ucs2_t *uni_reqpath = NULL;
int uni_reqpathoffset1, uni_reqpathoffset2;
int uni_curroffset;
int reply_size = 0;
@@ -1007,11 +1022,14 @@ static int setup_ver3_dfs_referral(const char *pathname,
DEBUG(10,("setting up version3 referral\n"));
- reqpathlen = rpcstr_push(uni_reqpath, pathname,
- sizeof(pstring), STR_TERMINATE);
+ reqpathlen = rpcstr_push_talloc(talloc_tos(), &uni_reqpath, pathname);
+ if (uni_reqpath == NULL || reqpathlen == 0) {
+ return -1;
+ }
if (DEBUGLVL(10)) {
- dump_data(0, uni_reqpath,reqpathlen);
+ dump_data(0, (unsigned char *)uni_reqpath,
+ reqpathlen);
}
uni_reqpathoffset1 = REFERRAL_HEADER_SIZE +
@@ -1069,8 +1087,8 @@ static int setup_ver3_dfs_referral(const char *pathname,
SSVAL(pdata,offset+14,uni_reqpathoffset2-offset);
/* copy referred path into current offset */
unilen = rpcstr_push(pdata+uni_curroffset,ref->alternate_path,
- sizeof(pstring),
- STR_UNICODE | STR_TERMINATE);
+ reply_size - uni_curroffset,
+ STR_UNICODE | STR_TERMINATE);
SSVAL(pdata,offset+16,uni_curroffset-offset);
/* copy 0x10 bytes of 00's in the ServiceSite GUID */
memset(pdata+offset+18,'\0',16);
@@ -1270,7 +1288,8 @@ static bool junction_to_local_path(const struct junction_map *jucn,
if(snum < 0) {
return False;
}
- if (!NT_STATUS_IS_OK(create_conn_struct(conn_out, snum,
+ if (!NT_STATUS_IS_OK(create_conn_struct(talloc_tos(),
+ conn_out, snum,
lp_pathname(snum)))) {
return False;
}
@@ -1402,7 +1421,8 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
* Fake up a connection struct for the VFS layer.
*/
- if (!NT_STATUS_IS_OK(create_conn_struct(&conn, snum, connect_path))) {
+ if (!NT_STATUS_IS_OK(create_conn_struct(talloc_tos(),
+ &conn, snum, connect_path))) {
return 0;
}
@@ -1467,7 +1487,7 @@ static int form_junctions(TALLOC_CTX *ctx,
* Fake up a connection struct for the VFS layer.
*/
- if (!NT_STATUS_IS_OK(create_conn_struct(&conn, snum, connect_path))) {
+ if (!NT_STATUS_IS_OK(create_conn_struct(ctx, &conn, snum, connect_path))) {
return 0;
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index c3972391f3..e98ce0f8c2 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -33,11 +33,7 @@ static bool canonicalize_connect_path(connection_struct *conn)
SAFE_FREE(resolved_name);
return ret;
#else
-#ifdef PATH_MAX
char resolved_name_buf[PATH_MAX+1];
-#else
- pstring resolved_name_buf;
-#endif
char *resolved_name = SMB_VFS_REALPATH(conn,conn->connectpath,resolved_name_buf);
if (!resolved_name) {
return false;
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 78939881d3..628d2eec4b 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -774,11 +774,7 @@ static void array_promote(char *array,int elsize,int element)
char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
{
-#ifdef PATH_MAX
char s[PATH_MAX+1];
-#else
- pstring s;
-#endif
static bool getwd_cache_init = False;
SMB_STRUCT_STAT st, st2;
int i;
@@ -893,11 +889,7 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
#ifdef REALPATH_TAKES_NULL
bool free_resolved_name = True;
#else
-#ifdef PATH_MAX
char resolved_name_buf[PATH_MAX+1];
-#else
- pstring resolved_name_buf;
-#endif
bool free_resolved_name = False;
#endif
char *resolved_name = NULL;
@@ -969,11 +961,7 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
return NT_STATUS_NO_MEMORY;
}
#else
-#ifdef PATH_MAX
safe_strcpy(resolved_name_buf, tmp_fname, PATH_MAX);
-#else
- pstrcpy(resolved_name_buf, tmp_fname);
-#endif
resolved_name = resolved_name_buf;
#endif
TALLOC_FREE(tmp_ctx);