Remove pstrings completely except for smbctool (what does this do ?).
authorJeremy Allison <jra@samba.org>
Fri, 7 Dec 2007 20:02:44 +0000 (12:02 -0800)
committerJeremy Allison <jra@samba.org>
Fri, 7 Dec 2007 20:02:44 +0000 (12:02 -0800)
Don't build this for now.
Jeremy.
(This used to be commit 46b67fd82c795d1a34a1efca9e409c0f3fa4f3a2)

source3/Makefile.in
source3/include/dynconfig.h
source3/include/includes.h
source3/include/msdfs.h
source3/include/pstring.h [deleted file]
source3/include/safe_string.h
source3/lib/util.c
source3/lib/util_str.c
source3/libsmb/clidfs.c
source3/nsswitch/winbind_nss_config.h

index 9917231c7a9dc44c75cca179a1bd36aa23a6a6d9..12c795e8efc9c913e60e51b67e4fe228fb93b2c3 100644 (file)
@@ -679,11 +679,11 @@ CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_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)
+#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
@@ -1168,9 +1168,9 @@ bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@
        @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 $@
index 996cf61492a2fa53f9963dfa7484c133673e5f3f..a26f840f6677f6d8a30ca15aafdd5532c7fdc821 100644 (file)
@@ -27,15 +27,15 @@ extern char const *dyn_SBINDIR,
        *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);
index 22530f76afc408b3329247fa3b6a9b96f0b3f209..67995fa4994b652bc18d32f1c1f17117ed019b7a 100644 (file)
@@ -617,8 +617,9 @@ struct timespec {
 #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"
@@ -1033,8 +1034,6 @@ int d_fprintf(FILE *f, const char *, ...) PRINTF_ATTRIBUTE(2,3);
 /* 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);
 
index c5bfac68d114c78ac4d2745d01d4301e1cd7b302..49b3ad4949f531f47bdef3c7f24eacd7342b200a 100644 (file)
@@ -40,7 +40,7 @@
 typedef struct _client_referral {
        uint32 proximity;
        uint32 ttl;
-       pstring dfspath;
+       char *dfspath;
 } CLIENT_DFS_REFERRAL;
 
 struct referral {
diff --git a/source3/include/pstring.h b/source3/include/pstring.h
deleted file mode 100644 (file)
index cf06ad8..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* 
-   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 */
index 439a0cf760340f7cd48793f32208e63b3bd2e918..c030acf8fdc2e152ae0d0b72c71e4b44935ac247 100644 (file)
@@ -86,16 +86,8 @@ size_t __unsafe_string_function_usage_here_char__(void);
 
 #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) \
@@ -105,8 +97,6 @@ size_t __unsafe_string_function_usage_here_char__(void);
    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)
index 3d653d9b80c7f9a680ddca1bed0f3cb843192d0a..83b122c6609f8babec83257094e018238be4aabc 100644 (file)
@@ -2211,9 +2211,9 @@ void dump_data(int level, const unsigned char *buf1,int len)
                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)
@@ -2229,10 +2229,10 @@ 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);
@@ -2254,7 +2254,7 @@ int str_checksum(const char *s)
        int res = 0;
        int c;
        int i=0;
-       
+
        while(*s) {
                c = *s;
                res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
@@ -2564,7 +2564,7 @@ char *pid_path(const char *name)
  *
  * @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)
index f26c8b8a77f73a8f15c24a97d610ce6cf0e30c59..0bf4ac83b2d0310d2c641db44e4cd36b215007d3 100644 (file)
@@ -1277,7 +1277,7 @@ void fstring_sub(char *s,const char *pattern,const char *insert)
 /**
  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.
 **/
 
@@ -1992,21 +1992,6 @@ char *binary_string(char *buf, int len)
        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.
index ef3d0e8db33d504a79c2a4bd5e35313ea972c4bf..5f95487d3f162c416971a108ed73356f7a2ad4d3 100644 (file)
@@ -570,7 +570,8 @@ static bool cli_dfs_check_error( struct cli_state *cli, NTSTATUS status )
  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,
@@ -579,83 +580,116 @@ bool cli_dfs_get_referral(struct cli_state *cli,
        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 = &param[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, &param_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;
 }
 
-
 /********************************************************************
 ********************************************************************/
 
@@ -667,7 +701,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
                        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;
@@ -746,15 +780,17 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
                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;
@@ -876,7 +912,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
                                char **pp_newshare )
 {
        CLIENT_DFS_REFERRAL *refs = NULL;
-       size_t num_refs;
+       size_t num_refs = 0;
        uint16 consumed;
        char *fullpath = NULL;
        bool res;
@@ -908,25 +944,25 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
                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;
        }
index e0828dc9052a550932984855b86cf085f8a116b3..70d1c5764f88be4d0e3f74c2701e0a9f483edb4f 100644 (file)
 /* 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 */