convert snprintf() calls using pstrings & fstrings
authorGerald Carter <jerry@samba.org>
Wed, 23 Jul 2003 12:33:59 +0000 (12:33 +0000)
committerGerald Carter <jerry@samba.org>
Wed, 23 Jul 2003 12:33:59 +0000 (12:33 +0000)
to pstr_sprintf() and fstr_sprintf() to try to standardize.
lots of snprintf() calls were using len-1; some were using
len.  At least this helps to be consistent.

25 files changed:
source/auth/auth_domain.c
source/client/client.c
source/client/tree.c
source/lib/smbldap.c
source/lib/util.c
source/lib/util_sock.c
source/libsmb/asn1.c
source/libsmb/cliconnect.c
source/libsmb/trustdom_cache.c
source/nsswitch/winbindd.c
source/nsswitch/winbindd_acct.c
source/nsswitch/winbindd_cache.c
source/nsswitch/winbindd_cm.c
source/passdb/pdb_ldap.c
source/rpc_server/srv_reg_nt.c
source/rpcclient/cmd_samr.c
source/sam/idmap_ldap.c
source/smbd/sesssetup.c
source/smbd/trans2.c
source/torture/mangle_test.c
source/torture/nsstest.c
source/torture/torture.c
source/utils/net_time.c
source/utils/ntlm_auth.c
source/web/swat.c

index 56bd6b9acab36c67ddd5b64b5503fb4b4efec118..e2fc273479a0280d05df6dcef77c603b96af5952 100644 (file)
@@ -104,7 +104,7 @@ machine %s. Error was : %s.\n", dc_name, cli_errstr(*cli)));
                return NT_STATUS_NO_LOGON_SERVERS;
        }
 
-       snprintf((*cli)->mach_acct, sizeof((*cli)->mach_acct) - 1, "%s$", setup_creds_as);
+       fstr_sprintf((*cli)->mach_acct, "%s$", setup_creds_as);
 
        if (!(*cli)->mach_acct) {
                release_server_mutex();
index 9cd9c81f23c5566c72076e6fe16dc11c88a4ed86..5319a5ebf5aa027037114e6895c0807967565f45 100644 (file)
@@ -2291,9 +2291,9 @@ static char **remote_completion(const char *text, int len)
        if (i > 0) {
                strncpy(info.dirmask, text, i+1);
                info.dirmask[i+1] = 0;
-               snprintf(dirmask, sizeof(dirmask), "%s%*s*", cur_dir, i-1, text);
+               pstr_sprintf(dirmask, "%s%*s*", cur_dir, i-1, text);
        } else
-               snprintf(dirmask, sizeof(dirmask), "%s*", cur_dir);
+               pstr_sprintf(dirmask, "%s*", cur_dir);
 
        if (cli_list(cli, dirmask, aDIR | aSYSTEM | aHIDDEN, completion_remote_filter, &info) < 0)
                goto cleanup;
index 3b90d15f65217ef12b8bd07d7b285655f6ceacae..97ad7742e314fe1b7a861a0efc87cfaa8cd31710 100644 (file)
@@ -69,7 +69,7 @@ static void tree_error_message(gchar *message) {
  * workgroup type and return a path from there
  */
 
-static char path_string[1024];
+static pstring path_string;
 
 char *get_path(GtkWidget *item)
 {
@@ -112,7 +112,7 @@ char *get_path(GtkWidget *item)
    * Now, build the path
    */
 
-  snprintf(path_string, sizeof(path_string), "smb:/");
+  pstrcpy( path_string, "smb:/" );
 
   for (j = i - 1; j >= 0; j--) {
 
@@ -151,7 +151,7 @@ static void cb_select_child (GtkWidget *root_tree, GtkWidget *child,
   char dirbuf[512];
   struct smbc_dirent *dirp;
   struct stat st1;
-  char path[1024], path1[1024];
+  pstring path, path1;
 
   g_print ("select_child called for root tree %p, subtree %p, child %p\n",
           root_tree, subtree, child);
index 7c2409312bc93aa7937b39562595c9642711a246..3f56d066ec0e400c778d566634b46e0c8d391473 100644 (file)
@@ -1197,7 +1197,7 @@ static NTSTATUS add_new_domain_info(struct smbldap_state *ldap_state,
        DEBUG(3,("Adding new domain\n"));
        ldap_op = LDAP_MOD_ADD;
 
-       snprintf(dn, sizeof(dn), "%s=%s,%s", get_attr_key2string(dominfo_attr_list, LDAP_ATTR_DOMAIN),
+       pstr_sprintf(dn, "%s=%s,%s", get_attr_key2string(dominfo_attr_list, LDAP_ATTR_DOMAIN),
                domain_name, lp_ldap_suffix());
 
        /* Free original search */
@@ -1262,7 +1262,7 @@ NTSTATUS smbldap_search_domain_info(struct smbldap_state *ldap_state,
        char **attr_list;
        int count;
 
-       snprintf(filter, sizeof(filter)-1, "(&(objectClass=%s)(%s=%s))",
+       pstr_sprintf(filter, "(&(objectClass=%s)(%s=%s))",
                LDAP_OBJ_DOMINFO,
                get_attr_key2string(dominfo_attr_list, LDAP_ATTR_DOMAIN), 
                domain_name);
index a7c939fe5a08a1ff482e8bab472d2d391a88d3fe..bcafad89a55fd670ea974e324baabbb227888191 100644 (file)
@@ -2247,7 +2247,7 @@ char *pid_path(const char *name)
 char *lib_path(const char *name)
 {
        static pstring fname;
-       snprintf(fname, sizeof(fname), "%s/%s", dyn_LIBDIR, name);
+       fstr_sprintf(fname, "%s/%s", dyn_LIBDIR, name);
        return fname;
 }
 
index 5320b504eb6257759528d6424d60d7d3cc77d5f4..b8b847170841c796705f9e6363954e73a35c4f84 100644 (file)
@@ -986,7 +986,7 @@ int create_pipe_sock(const char *socket_dir,
                 goto out_umask;
        }
         
-       snprintf(path, sizeof(path), "%s/%s", socket_dir, socket_name);
+       pstr_sprintf(path, "%s/%s", socket_dir, socket_name);
         
        unlink(path);
        memset(&sunaddr, 0, sizeof(sunaddr));
index 09d4fbb6c9abc42aaaec10ec524651064ff42565..576491dd3bcda47ae649c6aadcf1310f3d6afbb1 100644 (file)
@@ -322,9 +322,9 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID)
        asn1_read_uint8(data, &b);
 
        oid[0] = 0;
-       snprintf(el, sizeof(el), "%u",  b/40);
+       fstr_sprintf(el, "%u",  b/40);
        pstrcat(oid, el);
-       snprintf(el, sizeof(el), " %u",  b%40);
+       fstr_sprintf(el, " %u",  b%40);
        pstrcat(oid, el);
 
        while (asn1_tag_remaining(data) > 0) {
@@ -333,7 +333,7 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID)
                        asn1_read_uint8(data, &b);
                        v = (v<<7) | (b&0x7f);
                } while (!data->has_error && b & 0x80);
-               snprintf(el, sizeof(el), " %u",  v);
+               fstr_sprintf(el, " %u",  v);
                pstrcat(oid, el);
        }
 
index 49430616b324366212fe03580495e4de2b61960f..2188db2a624a9f546f9d7d116451d16472a7118f 100644 (file)
@@ -190,7 +190,7 @@ static BOOL cli_session_setup_plaintext(struct cli_state *cli, const char *user,
        char *p;
        fstring lanman;
        
-       snprintf( lanman, sizeof(lanman), "Samba %s", VERSION );
+       fstr_sprintf( lanman, "Samba %s", VERSION );
 
        set_message(cli->outbuf,13,0,True);
        SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
index 83781250880ceaf15fe2ce64dc458eccd8da5539..0128d08006235624c9ac20dcd6efe17428430bf7 100644 (file)
@@ -223,7 +223,7 @@ BOOL trustdom_cache_store_timestamp( uint32 t, time_t timeout )
        if (!gencache_init()) 
                return False;
                
-       snprintf(value, sizeof(value), "%d", t );
+       fstr_sprintf(value, "%d", t );
                
        if (!gencache_set(TDOMTSKEY, value, timeout)) {
                DEBUG(5, ("failed to set timestamp for trustdom_cache\n"));
index d8ff3c392e83b4d13be07e14860e31c4b9828584..8345fa11d0c33afa710c856f28b61df577e2deb0 100644 (file)
@@ -158,7 +158,7 @@ static void terminate(void)
        idmap_close();
        
        /* Remove socket file */
-       snprintf(path, sizeof(path), "%s/%s", 
+       pstr_sprintf(path, "%s/%s", 
                 WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME);
        unlink(path);
        exit(0);
@@ -824,7 +824,7 @@ int main(int argc, char **argv)
                exit(1);
        }
 
-       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
+       pstr_sprintf(logfile, "%s/log.winbindd", dyn_LOGFILEBASE);
        lp_set_logfile(logfile);
        setup_logging("winbindd", log_stdout);
        reopen_logs();
index a1e1478a6c3495d5453f0dc6ab1e2275d743cc8c..8abfd17110804a3ac024747227df214f4037669d 100644 (file)
@@ -161,7 +161,7 @@ static char* passwd2string( const WINBINDD_PW *pw )
        DEBUG(10,("passwd2string: converting passwd struct for %s\n", 
                pw->pw_name));
 
-       ret = snprintf( string, sizeof(string), "%s:%s:%lu:%lu:%s:%s:%s",
+       ret = pstr_sprintf( string, "%s:%s:%lu:%lu:%s:%s:%s",
                pw->pw_name, 
                pw->pw_passwd ? pw->pw_passwd : "x",
                (unsigned long)pw->pw_uid,
@@ -171,7 +171,7 @@ static char* passwd2string( const WINBINDD_PW *pw )
                pw->pw_shell );
                
        if ( ret < 0 ) {
-               DEBUG(0,("passwd2string: snprintf() failed!\n"));
+               DEBUG(0,("passwd2string: pstr_sprintf() failed!\n"));
                return NULL;
        }
                
@@ -303,7 +303,7 @@ static char* group2string( const WINBINDD_GR *grp )
                fstrcpy( gr_mem_str, "" );
        }
 
-       ret = snprintf( string, sizeof(string)-1, "%s:%s:%lu:%s",
+       ret = pstr_sprintf( string, "%s:%s:%lu:%s",
                grp->gr_name, 
                grp->gr_passwd ? grp->gr_passwd : "*",
                (unsigned long)grp->gr_gid,
@@ -312,7 +312,7 @@ static char* group2string( const WINBINDD_GR *grp )
        SAFE_FREE( gr_mem_str );
                
        if ( ret < 0 ) {
-               DEBUG(0,("group2string: snprintf() failed!\n"));
+               DEBUG(0,("group2string: pstr_sprintf() failed!\n"));
                return NULL;
        }
                
@@ -326,7 +326,7 @@ static char* acct_userkey_byname( const char *name )
 {
        static fstring key;
        
-       snprintf( key, sizeof(key), "%s/NAME/%s", WBKEY_PASSWD, name );
+       fstr_sprintf( key, "%s/NAME/%s", WBKEY_PASSWD, name );
        
        return key;             
 }
@@ -338,7 +338,7 @@ static char* acct_userkey_byuid( uid_t uid )
 {
        static fstring key;
        
-       snprintf( key, sizeof(key), "%s/UID/%lu", WBKEY_PASSWD, (unsigned long)uid );
+       fstr_sprintf( key, "%s/UID/%lu", WBKEY_PASSWD, (unsigned long)uid );
        
        return key;             
 }
@@ -350,7 +350,7 @@ static char* acct_groupkey_byname( const char *name )
 {
        static fstring key;
        
-       snprintf( key, sizeof(key), "%s/NAME/%s", WBKEY_GROUP, name );
+       fstr_sprintf( key, "%s/NAME/%s", WBKEY_GROUP, name );
        
        return key;             
 }
@@ -362,7 +362,7 @@ static char* acct_groupkey_bygid( gid_t gid )
 {
        static fstring key;
        
-       snprintf( key, sizeof(key), "%s/GID/%lu", WBKEY_GROUP, (unsigned long)gid );
+       fstr_sprintf( key, "%s/GID/%lu", WBKEY_GROUP, (unsigned long)gid );
        
        return key;             
 }
@@ -698,7 +698,7 @@ static int cleangroups_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA
        fstring key;
        char *name = (char*)state;
        
-       snprintf( key, sizeof(key), "%s/NAME", WBKEY_GROUP );
+       fstr_sprintf( key, "%s/NAME", WBKEY_GROUP );
        len = strlen(key);
        
        /* if this is a group entry then, check the members */
@@ -777,7 +777,7 @@ static int isprimarygroup_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf,
        fstring key;
        struct _check_primary_grp *check = (struct _check_primary_grp*)params;
        
-       snprintf( key, sizeof(key), "%s/NAME", WBKEY_PASSWD );
+       fstr_sprintf( key, "%s/NAME", WBKEY_PASSWD );
        len = strlen(key);
        
        /* if this is a group entry then, check the members */
index 2da2a9e641d51ac9e938751e354858bd268e7add..f1c85428153047861585920d197e72faf5fccd6f 100644 (file)
@@ -256,7 +256,7 @@ static NTSTATUS fetch_cache_seqnum( struct winbindd_domain *domain, time_t now )
                return NT_STATUS_UNSUCCESSFUL;
        }
                
-       snprintf( key, sizeof(key), "SEQNUM/%s", domain->name );
+       fstr_sprintf( key, "SEQNUM/%s", domain->name );
        
        data = tdb_fetch_bystring( wcache->tdb, key );
        if ( !data.dptr || data.dsize!=8 ) {
@@ -295,7 +295,7 @@ static NTSTATUS store_cache_seqnum( struct winbindd_domain *domain )
                return NT_STATUS_UNSUCCESSFUL;
        }
                
-       snprintf( key_str, sizeof(key_str), "SEQNUM/%s", domain->name );
+       fstr_sprintf( key_str, "SEQNUM/%s", domain->name );
        key.dptr = key_str;
        key.dsize = strlen(key_str)+1;
        
index 7f351677783d31fbf845f6a7db52b08972dc7783..9a1660685669a3bb6a33aaad6438ccf0d9d89c7e 100644 (file)
@@ -488,14 +488,14 @@ NTSTATUS cm_get_netlogon_cli(const char *domain,
        if (!NT_STATUS_IS_OK(result))
                return result;
        
-       snprintf(lock_name, sizeof(lock_name), "NETLOGON\\%s", conn->controller);
+       fstr_sprintf(lock_name, "NETLOGON\\%s", conn->controller);
 
        if (!(got_mutex = secrets_named_mutex(lock_name, WINBIND_SERVER_MUTEX_WAIT_TIME))) {
                DEBUG(0,("cm_get_netlogon_cli: mutex grab failed for %s\n", conn->controller));
        }
        
        if ( sec_channel_type == SEC_CHAN_DOMAIN )
-               snprintf(conn->cli->mach_acct, sizeof(conn->cli->mach_acct) - 1, "%s$", lp_workgroup());
+               fstr_sprintf(conn->cli->mach_acct, "%s$", lp_workgroup());
                        
        result = cli_nt_establish_netlogon(conn->cli, sec_channel_type, trust_passwd);
        
index 1770ef8b8a82a4accf22970ac1a2d97933a55713..aee6495759308a362026277c5ef6794c9bd6b3e4 100644 (file)
@@ -161,10 +161,10 @@ static const char* get_objclass_filter( int schema_ver )
        switch( schema_ver ) 
        {
                case SCHEMAVER_SAMBAACCOUNT:
-                       snprintf( objclass_filter, sizeof(objclass_filter)-1, "(objectclass=%s)", LDAP_OBJ_SAMBAACCOUNT );
+                       fstr_sprintf( objclass_filter, "(objectclass=%s)", LDAP_OBJ_SAMBAACCOUNT );
                        break;
                case SCHEMAVER_SAMBASAMACCOUNT:
-                       snprintf( objclass_filter, sizeof(objclass_filter)-1, "(objectclass=%s)", LDAP_OBJ_SAMBASAMACCOUNT );
+                       fstr_sprintf( objclass_filter, "(objectclass=%s)", LDAP_OBJ_SAMBASAMACCOUNT );
                        break;
                default:
                        DEBUG(0,("pdb_ldapsam: get_objclass_filter(): Invalid schema version specified!\n"));
@@ -192,7 +192,7 @@ static int ldapsam_search_suffix_by_name (struct ldapsam_privates *ldap_state,
         * in the filter expression, replace %u with the real name
         * so in ldap filter, %u MUST exist :-)
         */
-       snprintf(filter, sizeof(filter)-1, "(&%s%s)", lp_ldap_filter(), 
+       pstr_sprintf(filter, "(&%s%s)", lp_ldap_filter(), 
                get_objclass_filter(ldap_state->schema_ver));
 
        /* 
@@ -217,7 +217,7 @@ static int ldapsam_search_suffix_by_rid (struct ldapsam_privates *ldap_state,
        pstring filter;
        int rc;
 
-       snprintf(filter, sizeof(filter)-1, "(&(rid=%i)%s)", rid, 
+       pstr_sprintf(filter, "(&(rid=%i)%s)", rid, 
                get_objclass_filter(ldap_state->schema_ver));
        
        rc = smbldap_search_suffix(ldap_state->smbldap_state, filter, attr, result);
@@ -236,7 +236,7 @@ static int ldapsam_search_suffix_by_sid (struct ldapsam_privates *ldap_state,
        int rc;
        fstring sid_string;
 
-       snprintf(filter, sizeof(filter)-1, "(&(%s=%s)%s)", 
+       pstr_sprintf(filter, "(&(%s=%s)%s)", 
                get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_USER_SID),
                sid_to_string(sid_string, sid), 
                get_objclass_filter(ldap_state->schema_ver));
@@ -956,7 +956,7 @@ static NTSTATUS ldapsam_setsampwent(struct pdb_methods *my_methods, BOOL update)
        pstring filter;
        char **attr_list;
 
-       snprintf( filter, sizeof(filter)-1, "(&%s%s)", lp_ldap_filter(), 
+       pstr_sprintf( filter, "(&%s%s)", lp_ldap_filter(), 
                get_objclass_filter(ldap_state->schema_ver));
        all_string_sub(filter, "%u", "*", sizeof(pstring));
 
@@ -1519,7 +1519,7 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCO
 
                /* There might be a SID for this account already - say an idmap entry */
 
-               snprintf(filter, sizeof(filter)-1, "(&(%s=%s)(|(objectClass=%s)(objectClass=%s)))", 
+               pstr_sprintf(filter, "(&(%s=%s)(|(objectClass=%s)(objectClass=%s)))", 
                         get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_USER_SID),
                         sid_to_string(sid_string, sid),
                         LDAP_OBJ_IDMAP_ENTRY,
@@ -1737,7 +1737,7 @@ static BOOL init_ldap_from_group(LDAP *ldap_struct,
        sid_to_string(tmp, &map->sid);
        smbldap_make_mod(ldap_struct, existing, mods, 
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_GROUP_SID), tmp);
-       snprintf(tmp, sizeof(tmp)-1, "%i", map->sid_name_use);
+       pstr_sprintf(tmp, "%i", map->sid_name_use);
        smbldap_make_mod(ldap_struct, existing, mods, 
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_GROUP_TYPE), tmp);
 
@@ -1808,7 +1808,7 @@ static NTSTATUS ldapsam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
 {
        pstring filter;
 
-       snprintf(filter, sizeof(filter)-1, "(&(objectClass=%s)(%s=%s))",
+       pstr_sprintf(filter, "(&(objectClass=%s)(%s=%s))",
                LDAP_OBJ_GROUPMAP, 
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_GROUP_SID),
                sid_string_static(&sid));
@@ -1824,7 +1824,7 @@ static NTSTATUS ldapsam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
 {
        pstring filter;
 
-       snprintf(filter, sizeof(filter)-1, "(&(objectClass=%s)(%s=%lu))",
+       pstr_sprintf(filter, "(&(objectClass=%s)(%s=%lu))",
                LDAP_OBJ_GROUPMAP,
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_GIDNUMBER),
                (unsigned long)gid);
@@ -1845,7 +1845,7 @@ static NTSTATUS ldapsam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
                return NT_STATUS_NO_MEMORY;
        }
 
-       snprintf(filter, sizeof(filter)-1, "(&(objectClass=%s)(|(%s=%s)(%s=%s)))",
+       pstr_sprintf(filter, "(&(objectClass=%s)(|(%s=%s)(%s=%s)))",
                LDAP_OBJ_GROUPMAP,
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_DISPLAY_NAME), escape_name,
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_CN), escape_name);
@@ -1864,7 +1864,7 @@ static int ldapsam_search_one_group_by_gid(struct ldapsam_privates *ldap_state,
 {
        pstring filter;
 
-       snprintf(filter, sizeof(filter)-1, "(&(objectClass=%s)(%s=%lu))", 
+       pstr_sprintf(filter, "(&(objectClass=%s)(%s=%lu))", 
                LDAP_OBJ_POSIXGROUP,
                get_attr_key2string(groupmap_attr_list, LDAP_ATTR_GIDNUMBER),
                (unsigned long)gid);
@@ -2032,7 +2032,7 @@ static NTSTATUS ldapsam_delete_group_mapping_entry(struct pdb_methods *methods,
 
        sid_to_string(sidstring, &sid);
        
-       snprintf(filter, sizeof(filter)-1, "(&(objectClass=%s)(%s=%s))", 
+       pstr_sprintf(filter, "(&(objectClass=%s)(%s=%s))", 
                LDAP_OBJ_GROUPMAP, LDAP_ATTRIBUTE_SID, sidstring);
 
        rc = ldapsam_search_one_group(ldap_state, filter, &result);
@@ -2060,7 +2060,7 @@ static NTSTATUS ldapsam_setsamgrent(struct pdb_methods *my_methods, BOOL update)
        int rc;
        char **attr_list;
 
-       snprintf( filter, sizeof(filter)-1, "(objectclass=%s)", LDAP_OBJ_GROUPMAP);
+       pstr_sprintf( filter, "(objectclass=%s)", LDAP_OBJ_GROUPMAP);
        attr_list = get_attr_list( groupmap_attr_list );
        rc = smbldap_search(ldap_state->smbldap_state, lp_ldap_group_suffix(),
                            LDAP_SCOPE_SUBTREE, filter,
index 5632544909ad628aecdd5047e2ffda2b0e5fdcc0..a4e3638be605494772f6e9cdbfa4a45a0f131cd0 100644 (file)
@@ -596,11 +596,11 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u
                /* security check */
        alpha_strcpy (chkmsg, message, NULL, sizeof(message));
        /* timeout */
-       snprintf(timeout, sizeof(timeout), "%d", q_u->timeout);
+       fstr_sprintf(timeout, "%d", q_u->timeout);
        /* reboot */
-       snprintf(r, sizeof(r), (q_u->reboot) ? SHUTDOWN_R_STRING : "");
+       fstr_sprintf(r, (q_u->reboot) ? SHUTDOWN_R_STRING : "");
        /* force */
-       snprintf(f, sizeof(f), (q_u->force) ? SHUTDOWN_F_STRING : "");
+       fstr_sprintf(f, (q_u->force) ? SHUTDOWN_F_STRING : "");
 
        pstrcpy(shutdown_script, lp_shutdown_script());
 
index 40d01d0f5a2383f95a80cd4196b5c558175708bc..722d66621a628c2a89c08e610351ab895780e71d 100644 (file)
@@ -125,7 +125,7 @@ static const char *display_time(NTTIME nttime)
        mins=(sec - (days*60*60*24) - (hours*60*60) ) / 60;
        secs=sec - (days*60*60*24) - (hours*60*60) - (mins*60);
 
-       snprintf(string, sizeof(string)-1, "%u days, %u hours, %u minutes, %u seconds", days, hours, mins, secs);
+       fstr_sprintf(string, "%u days, %u hours, %u minutes, %u seconds", days, hours, mins, secs);
        return (string);
 }
 
index 6a9461d292bf1ae9e7b0250cee2f0ccfd6c55d5b..92962b8499013918fc3f21ff75c7ee25d4c6e764 100644 (file)
@@ -361,7 +361,7 @@ static NTSTATUS ldap_allocate_id(unid_t *id, int id_type)
                get_attr_key2string( idpool_attr_list, LDAP_ATTR_UIDNUMBER ) : 
                get_attr_key2string( idpool_attr_list, LDAP_ATTR_GIDNUMBER );
 
-       snprintf(filter, sizeof(filter)-1, "(objectClass=%s)", LDAP_OBJ_IDPOOL);
+       pstr_sprintf(filter, "(objectClass=%s)", LDAP_OBJ_IDPOOL);
 
        attr_list = get_attr_list( idpool_attr_list );
        
@@ -414,7 +414,7 @@ static NTSTATUS ldap_allocate_id(unid_t *id, int id_type)
                }
        }
        
-       snprintf(new_id_str, sizeof(new_id_str), "%lu", 
+       pstr_sprintf(new_id_str, "%lu", 
                 ((id_type & ID_USERID) ? (unsigned long)id->uid : 
                  (unsigned long)id->gid) + 1);
                 
@@ -461,18 +461,18 @@ static NTSTATUS ldap_get_sid_from_id(DOM_SID *sid, unid_t id, int id_type)
        if ( id_type & ID_USERID ) {
                type = get_attr_key2string( idpool_attr_list, LDAP_ATTR_UIDNUMBER );
                obj_class = LDAP_OBJ_SAMBASAMACCOUNT;
-               snprintf(id_str, sizeof(id_str), "%lu", (unsigned long)id.uid );        
+               fstr_sprintf(id_str, "%lu", (unsigned long)id.uid );    
                pstrcpy( suffix, lp_ldap_suffix());
        }
        else {
                type = get_attr_key2string( idpool_attr_list, LDAP_ATTR_GIDNUMBER );
                obj_class = LDAP_OBJ_GROUPMAP;
-               snprintf(id_str, sizeof(id_str), "%lu", (unsigned long)id.gid );        
+               fstr_sprintf(id_str, "%lu", (unsigned long)id.gid );    
                pstrcpy( suffix, lp_ldap_group_suffix() );
        }
                 
        attr_list = get_attr_list( sidmap_attr_list );
-       snprintf(filter, sizeof(filter), "(&(|(objectClass=%s)(objectClass=%s))(%s=%s))", 
+       pstr_sprintf(filter, "(&(|(objectClass=%s)(objectClass=%s))(%s=%s))", 
                 LDAP_OBJ_IDMAP_ENTRY, obj_class, type, id_str);
 
        rc = smbldap_search(ldap_state.smbldap_state, suffix, LDAP_SCOPE_SUBTREE, 
@@ -490,7 +490,7 @@ static NTSTATUS ldap_get_sid_from_id(DOM_SID *sid, unid_t id, int id_type)
                ldap_msgfree(result);
                result = NULL;
                
-               snprintf(filter, sizeof(filter), "(&(objectClass=%s)(%s=%lu))",
+               pstr_sprintf(filter, "(&(objectClass=%s)(%s=%lu))",
                        LDAP_OBJ_IDMAP_ENTRY, type,  
                         ((id_type & ID_USERID) ? (unsigned long)id.uid : 
                          (unsigned long)id.gid));
@@ -560,8 +560,7 @@ static NTSTATUS ldap_get_id_from_sid(unid_t *id, int *id_type, const DOM_SID *si
                obj_class = LDAP_OBJ_SAMBASAMACCOUNT;
                posix_obj_class = LDAP_OBJ_POSIXACCOUNT;
                suffix = lp_ldap_suffix();
-               snprintf(filter, sizeof(filter), 
-                        "(&(|(&(objectClass=%s)(objectClass=%s))(objectClass=%s))(%s=%s))", 
+               pstr_sprintf(filter, "(&(|(&(objectClass=%s)(objectClass=%s))(objectClass=%s))(%s=%s))", 
                         obj_class, posix_obj_class, LDAP_OBJ_IDMAP_ENTRY, 
                         get_attr_key2string( sidmap_attr_list, LDAP_ATTR_SID ), 
                         sid_str);
@@ -571,8 +570,7 @@ static NTSTATUS ldap_get_id_from_sid(unid_t *id, int *id_type, const DOM_SID *si
                obj_class = LDAP_OBJ_GROUPMAP;
                posix_obj_class = LDAP_OBJ_POSIXGROUP;
                suffix = lp_ldap_group_suffix();
-               snprintf(filter, sizeof(filter), 
-                        "(&(|(objectClass=%s)(objectClass=%s))(%s=%s))", 
+               pstr_sprintf(filter, "(&(|(objectClass=%s)(objectClass=%s))(%s=%s))", 
                         obj_class, LDAP_OBJ_IDMAP_ENTRY, 
                         get_attr_key2string( sidmap_attr_list, LDAP_ATTR_SID ), 
                         sid_str);
@@ -593,7 +591,7 @@ static NTSTATUS ldap_get_id_from_sid(unid_t *id, int *id_type, const DOM_SID *si
        if (count == 0) {
                ldap_msgfree(result);
                
-               snprintf(filter, sizeof(filter), "(&(objectClass=%s)(%s=%s))", 
+               pstr_sprintf(filter, "(&(objectClass=%s)(%s=%s))", 
                        LDAP_OBJ_IDMAP_ENTRY, LDAP_ATTRIBUTE_SID, sid_str);
 
                suffix = lp_ldap_idmap_suffix();
@@ -676,7 +674,7 @@ static NTSTATUS ldap_set_mapping_internals(const DOM_SID *sid, unid_t id,
                                           int id_type, const char *ldap_dn, 
                                           LDAPMessage *entry)
 {
-       char *dn = NULL;
+       pstring dn; 
        pstring id_str;
        fstring type;
        LDAPMod **mods = NULL;
@@ -691,24 +689,19 @@ static NTSTATUS ldap_set_mapping_internals(const DOM_SID *sid, unid_t id,
        if (ldap_dn) {
                DEBUG(10, ("Adding new IDMAP mapping on DN: %s", ldap_dn));
                ldap_op = LDAP_MOD_REPLACE;
-               dn = strdup(ldap_dn);
+               pstrcpy( dn, ldap_dn );
        } else {
                ldap_op = LDAP_MOD_ADD;
-               asprintf(&dn, "%s=%s,%s", get_attr_key2string( sidmap_attr_list, LDAP_ATTR_SID), 
+               pstr_sprintf(dn, "%s=%s,%s", get_attr_key2string( sidmap_attr_list, LDAP_ATTR_SID), 
                         sid_string, lp_ldap_idmap_suffix());
        }
        
-       if (!dn) {
-               DEBUG(0, ("ldap_set_mapping_internals: out of memory allocating DN!\n"));
-               return NT_STATUS_NO_MEMORY;
-       }
-
        if ( id_type & ID_USERID ) 
                fstrcpy( type, get_attr_key2string( sidmap_attr_list, LDAP_ATTR_UIDNUMBER ) );
        else
                fstrcpy( type, get_attr_key2string( sidmap_attr_list, LDAP_ATTR_GIDNUMBER ) );
 
-       snprintf(id_str, sizeof(id_str), "%lu", ((id_type & ID_USERID) ? (unsigned long)id.uid : 
+       pstr_sprintf(id_str, "%lu", ((id_type & ID_USERID) ? (unsigned long)id.uid : 
                                                 (unsigned long)id.gid));       
        
        if (entry) 
@@ -802,18 +795,18 @@ static NTSTATUS ldap_set_mapping(const DOM_SID *sid, unid_t id, int id_type)
                suffix = lp_ldap_suffix();
                type = get_attr_key2string( idpool_attr_list, LDAP_ATTR_UIDNUMBER );
                posix_obj_class = LDAP_OBJ_POSIXACCOUNT;
-               snprintf(id_str, sizeof(id_str), "%u", id.uid );        
+               fstr_sprintf(id_str, "%u", id.uid );    
        }
        else {
                obj_class = LDAP_OBJ_GROUPMAP;
                suffix = lp_ldap_group_suffix();
                type = get_attr_key2string( idpool_attr_list, LDAP_ATTR_GIDNUMBER );
                posix_obj_class = LDAP_OBJ_POSIXGROUP;
-               snprintf(id_str, sizeof(id_str), "%u", id.gid );        
+               fstr_sprintf(id_str, "%u", id.gid );    
        }
        
        sid_to_string(sid_str, sid);
-       snprintf(filter, sizeof(filter)
+       pstr_sprintf(filter
                 "(|"
                 "(&(|(objectClass=%s)(|(objectClass=%s)(objectClass=%s)))(%s=%s))"
                 "(&(objectClass=%s)(%s=%s))"
@@ -895,7 +888,7 @@ static NTSTATUS ldap_idmap_init( char *params )
 
        /* see if the idmap suffix and sub entries exists */
        
-       snprintf( filter, sizeof(filter), "(objectclass=%s)", LDAP_OBJ_IDPOOL );
+       fstr_sprintf( filter, "(objectclass=%s)", LDAP_OBJ_IDPOOL );
        
        attr_list = get_attr_list( idpool_attr_list );
        rc = smbldap_search(ldap_state.smbldap_state, lp_ldap_idmap_suffix(), 
@@ -922,8 +915,8 @@ static NTSTATUS ldap_idmap_init( char *params )
                        return NT_STATUS_UNSUCCESSFUL;
                }
                
-               snprintf( uid_str, sizeof(uid_str), "%d", luid );
-               snprintf( gid_str, sizeof(gid_str), "%d", lgid );
+               fstr_sprintf( uid_str, "%d", luid );
+               fstr_sprintf( gid_str, "%d", lgid );
 
                smbldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_IDPOOL );
                smbldap_set_mod( &mods, LDAP_MOD_ADD, 
index 9ec5433b0246a90a1e066f0171fe1da4937280d1..767bf8415442f1bd6f10697b9c0885174115ed67 100644 (file)
@@ -62,7 +62,7 @@ static int add_signature(char *outbuf, char *p)
        char *start = p;
        fstring lanman;
 
-       snprintf( lanman, sizeof(lanman), "Samba %s", VERSION );
+       fstr_sprintf( lanman, "Samba %s", VERSION );
 
        p += srvstr_push(outbuf, p, "Unix", -1, STR_TERMINATE);
        p += srvstr_push(outbuf, p, lanman, -1, STR_TERMINATE);
index 398646a6cd8154a1a4caed1336a70bfe98028007..99988877938902ed5bf45f09abb4c003d2a66127 100644 (file)
@@ -1912,7 +1912,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
        if (strequal(base_name,".")) {
                pstrcpy(dos_fname, "\\");
        } else {
-               snprintf(dos_fname, sizeof(dos_fname), "\\%s", fname);
+               pstr_sprintf(dos_fname, "\\%s", fname);
                string_replace(dos_fname, '/', '\\');
        }
 
index 660d4d17af290f479ad6baf28a2f9f089131825a..9a719349b651530b612363c7074a02fb9555d455 100644 (file)
@@ -54,7 +54,7 @@ static BOOL test_one(struct cli_state *cli, const char *name)
                return False;
        }
 
-       snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname);
+       fstr_sprintf(name2, "\\mangle_test\\%s", shortname);
        if (!cli_unlink(cli, name2)) {
                printf("unlink of %s  (%s) failed (%s)\n", 
                       name2, name, cli_errstr(cli));
index b5cd59d50bc93555226deb763a088195cf20a825..a803cd7e719e9585968e55a4af58b2f5817df665 100644 (file)
@@ -29,11 +29,11 @@ static int total_errors;
 
 static void *find_fn(const char *name)
 {
-       char s[1024];
+       pstring s;
        static void *h;
        void *res;
 
-       snprintf(s,sizeof(s), "_nss_%s_%s", nss_name, name);
+       pstr_sprintf(s, "_nss_%s_%s", nss_name, name);
 
        if (!h) {
                h = sys_dlopen(so_path, RTLD_LAZY);
index f26ebb49b30e4290690646883063b2b2ab9d48b3..0be79d04a94d430bb20a13fff2ea08661ff4ae40 100644 (file)
@@ -4366,7 +4366,7 @@ static BOOL run_error_map_extract(int dummy) {
        }
 
        for (error=(0xc0000000 | 0x1); error < (0xc0000000| 0xFFF); error++) {
-               snprintf(user, sizeof(user), "%X", error);
+               fstr_sprintf(user, "%X", error);
 
                if (cli_session_setup(&c_nt, user, 
                                       password, strlen(password),
@@ -4586,7 +4586,7 @@ static BOOL run_test(const char *name)
        }
        
        for (i=0;torture_ops[i].name;i++) {
-               snprintf(randomfname, sizeof(randomfname), "\\XX%x", 
+               fstr_sprintf(randomfname, "\\XX%x", 
                         (unsigned)random());
 
                if (strequal(name, torture_ops[i].name)) {
index 40619a0796d23680603d5f4fa15eb90d2c51ede5..45c17838055e9761b60c2ef4f6a21f7dc8b7d585 100644 (file)
@@ -71,12 +71,12 @@ static time_t nettime(int *zone)
 /* return a time as a string ready to be passed to /bin/date */
 static char *systime(time_t t)
 {
-       static char s[100];
+       static fstring s;
        struct tm *tm;
 
        tm = localtime(&t);
        
-       snprintf(s, sizeof(s), "%02d%02d%02d%02d%04d.%02d", 
+       fstr_sprintf(s, "%02d%02d%02d%02d%04d.%02d", 
                 tm->tm_mon+1, tm->tm_mday, tm->tm_hour, 
                 tm->tm_min, tm->tm_year + 1900, tm->tm_sec);
        return s;
index 3dfa157bdaba0ff6684dc137f2fba107e3638d02..a84f9b30f5d98df80d3196eb6dfe995b5ea3f7a7 100644 (file)
@@ -1372,7 +1372,7 @@ enum {
        } else {
                fstring user;
 
-               snprintf(user, sizeof(user)-1, "%s%c%s", opt_domain, winbind_separator(), opt_username);
+               fstr_sprintf(user, "%s%c%s", opt_domain, winbind_separator(), opt_username);
                if (!check_plaintext_auth(user, opt_password, True)) {
                        exit(1);
                }
index 7326e95415212d8232bc8b77b188615f0a13aecf..b43cdd08f105a96c3a7a5cdfd3f84dd1fc21dec3 100644 (file)
@@ -164,12 +164,12 @@ static const char* get_parm_translated(
        static pstring output;
        if(strcmp(pLabel, pTranslated) != 0)
        {
-               snprintf(output, sizeof(output),
+               pstr_sprintf(output,
                  "<A HREF=\"/swat/help/smb.conf.5.html#%s\" target=\"docs\"> %s</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %s <br><span class=\"i18n_translated_parm\">%s</span>",
                   pAnchor, pHelp, pLabel, pTranslated);
                return output;
        }
-       snprintf(output, sizeof(output)
+       pstr_sprintf(output
          "<A HREF=\"/swat/help/smb.conf.5.html#%s\" target=\"docs\"> %s</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %s",
          pAnchor, pHelp, pLabel);
        return output;