summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/auth/auth_domain.c2
-rw-r--r--source3/client/client.c4
-rw-r--r--source3/client/tree.c6
-rw-r--r--source3/lib/smbldap.c4
-rw-r--r--source3/lib/util.c2
-rw-r--r--source3/lib/util_sock.c2
-rw-r--r--source3/libsmb/asn1.c6
-rw-r--r--source3/libsmb/cliconnect.c2
-rw-r--r--source3/libsmb/trustdom_cache.c2
-rw-r--r--source3/nsswitch/winbindd.c4
-rw-r--r--source3/nsswitch/winbindd_acct.c20
-rw-r--r--source3/nsswitch/winbindd_cache.c4
-rw-r--r--source3/nsswitch/winbindd_cm.c4
-rw-r--r--source3/passdb/pdb_ldap.c28
-rw-r--r--source3/rpc_server/srv_reg_nt.c6
-rw-r--r--source3/rpcclient/cmd_samr.c2
-rw-r--r--source3/sam/idmap_ldap.c45
-rw-r--r--source3/smbd/sesssetup.c2
-rw-r--r--source3/smbd/trans2.c2
-rw-r--r--source3/torture/mangle_test.c2
-rw-r--r--source3/torture/nsstest.c4
-rw-r--r--source3/torture/torture.c4
-rw-r--r--source3/utils/net_time.c4
-rw-r--r--source3/utils/ntlm_auth.c2
-rw-r--r--source3/web/swat.c4
25 files changed, 80 insertions, 87 deletions
diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c
index 56bd6b9aca..e2fc273479 100644
--- a/source3/auth/auth_domain.c
+++ b/source3/auth/auth_domain.c
@@ -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();
diff --git a/source3/client/client.c b/source3/client/client.c
index 9cd9c81f23..5319a5ebf5 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -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;
diff --git a/source3/client/tree.c b/source3/client/tree.c
index 3b90d15f65..97ad7742e3 100644
--- a/source3/client/tree.c
+++ b/source3/client/tree.c
@@ -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);
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 7c2409312b..3f56d066ec 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -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);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index a7c939fe5a..bcafad89a5 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -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;
}
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 5320b504eb..b8b8471708 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -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));
diff --git a/source3/libsmb/asn1.c b/source3/libsmb/asn1.c
index 09d4fbb6c9..576491dd3b 100644
--- a/source3/libsmb/asn1.c
+++ b/source3/libsmb/asn1.c
@@ -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);
}
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 49430616b3..2188db2a62 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -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);
diff --git a/source3/libsmb/trustdom_cache.c b/source3/libsmb/trustdom_cache.c
index 8378125088..0128d08006 100644
--- a/source3/libsmb/trustdom_cache.c
+++ b/source3/libsmb/trustdom_cache.c
@@ -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"));
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index d8ff3c392e..8345fa11d0 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -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();
diff --git a/source3/nsswitch/winbindd_acct.c b/source3/nsswitch/winbindd_acct.c
index a1e1478a6c..8abfd17110 100644
--- a/source3/nsswitch/winbindd_acct.c
+++ b/source3/nsswitch/winbindd_acct.c
@@ -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 */
diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c
index 2da2a9e641..f1c8542815 100644
--- a/source3/nsswitch/winbindd_cache.c
+++ b/source3/nsswitch/winbindd_cache.c
@@ -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;
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index 7f35167778..9a16606856 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -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);
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 1770ef8b8a..aee6495759 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -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,
diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c
index 5632544909..a4e3638be6 100644
--- a/source3/rpc_server/srv_reg_nt.c
+++ b/source3/rpc_server/srv_reg_nt.c
@@ -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());
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 40d01d0f5a..722d66621a 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -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);
}
diff --git a/source3/sam/idmap_ldap.c b/source3/sam/idmap_ldap.c
index 6a9461d292..92962b8499 100644
--- a/source3/sam/idmap_ldap.c
+++ b/source3/sam/idmap_ldap.c
@@ -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,
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 9ec5433b02..767bf84154 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -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);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 398646a6cd..9998887793 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -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, '/', '\\');
}
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c
index 660d4d17af..9a719349b6 100644
--- a/source3/torture/mangle_test.c
+++ b/source3/torture/mangle_test.c
@@ -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));
diff --git a/source3/torture/nsstest.c b/source3/torture/nsstest.c
index b5cd59d50b..a803cd7e71 100644
--- a/source3/torture/nsstest.c
+++ b/source3/torture/nsstest.c
@@ -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);
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index f26ebb49b3..0be79d04a9 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -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)) {
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 40619a0796..45c1783805 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -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;
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index 3dfa157bda..a84f9b30f5 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -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);
}
diff --git a/source3/web/swat.c b/source3/web/swat.c
index 7326e95415..b43cdd08f1 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -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;