From f9a15ce1a69f905e94db7650f0a4805720cd9c88 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 8 Apr 2001 20:22:39 +0000 Subject: [PATCH] Got "medieval on our ass" about adding the -1 to slprintf. Jeremy. (This used to be commit 94747b4639ed9b19f7d0fb896e43aa392a84989a) --- source3/client/client.c | 2 +- source3/client/smbmnt.c | 2 +- source3/client/smbmount.c | 8 ++++---- source3/lib/charset.c | 2 +- source3/lib/messages.c | 2 +- source3/lib/substitute.c | 2 +- source3/lib/util.c | 2 +- source3/lib/util_str.c | 2 +- source3/lib/util_unistr.c | 4 ++-- source3/libsmb/cli_spoolss.c | 12 ++++++------ source3/libsmb/namequery.c | 2 +- source3/msdfs/msdfs.c | 2 +- source3/nmbd/nmbd.c | 2 +- source3/nmbd/nmbd_winsserver.c | 8 ++++---- source3/nsswitch/winbindd.c | 6 +++--- source3/nsswitch/winbindd_cache.c | 30 +++++++++++++++--------------- source3/nsswitch/winbindd_group.c | 6 +++--- source3/nsswitch/winbindd_idmap.c | 6 +++--- source3/nsswitch/winbindd_pam.c | 2 +- source3/nsswitch/winbindd_user.c | 4 ++-- source3/passdb/secrets.c | 6 +++--- source3/printing/printing.c | 20 ++++++++++---------- source3/rpc_parse/parse_prs.c | 4 ++-- source3/rpc_server/srv_pipe.c | 4 ++-- source3/rpcclient/cmd_samr.c | 8 ++++---- source3/rpcclient/cmd_spoolss.c | 12 ++++++------ source3/smbd/connection.c | 2 +- source3/smbd/dfree.c | 2 +- source3/smbd/process.c | 2 +- source3/smbd/reply.c | 2 +- source3/smbd/server.c | 2 +- 31 files changed, 85 insertions(+), 85 deletions(-) diff --git a/source3/client/client.c b/source3/client/client.c index 04a30ffb212..65f3a7a75ec 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -1838,7 +1838,7 @@ static void process_stdin(void) int i; /* display a prompt */ - slprintf(prompt, sizeof(prompt), "smb: %s> ", cur_dir); + slprintf(prompt, sizeof(prompt)-1, "smb: %s> ", cur_dir); line = smb_readline(prompt, readline_callback, completion_fn); if (!line) break; diff --git a/source3/client/smbmnt.c b/source3/client/smbmnt.c index 209d50ab810..36248987b1e 100644 --- a/source3/client/smbmnt.c +++ b/source3/client/smbmnt.c @@ -160,7 +160,7 @@ do_mount(char *share_name, unsigned int flags, struct smb_mount_data *data) data2 = (char *) data; } - slprintf(opts, sizeof(opts), + slprintf(opts, sizeof(opts)-1, "version=7,uid=%d,gid=%d,file_mode=0%o,dir_mode=0%o,%s", data->uid, data->gid, data->file_mode, data->dir_mode,options); if (mount(share_name, ".", "smbfs", flags, data1) == 0) diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c index 9b92cf261a0..35677815fff 100644 --- a/source3/client/smbmount.c +++ b/source3/client/smbmount.c @@ -455,22 +455,22 @@ static void init_mount(void) args[i++] = "-r"; } if (mount_uid) { - slprintf(tmp, sizeof(tmp), "%d", mount_uid); + slprintf(tmp, sizeof(tmp)-1, "%d", mount_uid); args[i++] = "-u"; args[i++] = xstrdup(tmp); } if (mount_gid) { - slprintf(tmp, sizeof(tmp), "%d", mount_gid); + slprintf(tmp, sizeof(tmp)-1, "%d", mount_gid); args[i++] = "-g"; args[i++] = xstrdup(tmp); } if (mount_fmask) { - slprintf(tmp, sizeof(tmp), "0%o", mount_fmask); + slprintf(tmp, sizeof(tmp)-1, "0%o", mount_fmask); args[i++] = "-f"; args[i++] = xstrdup(tmp); } if (mount_dmask) { - slprintf(tmp, sizeof(tmp), "0%o", mount_dmask); + slprintf(tmp, sizeof(tmp)-1, "0%o", mount_dmask); args[i++] = "-d"; args[i++] = xstrdup(tmp); } diff --git a/source3/lib/charset.c b/source3/lib/charset.c index fcaca79b885..d699df3e2b8 100644 --- a/source3/lib/charset.c +++ b/source3/lib/charset.c @@ -205,7 +205,7 @@ static codepage_p load_client_codepage( int client_codepage ) pstrcat(codepage_file_name, "/"); pstrcat(codepage_file_name, "codepage."); slprintf(&codepage_file_name[strlen(codepage_file_name)], - sizeof(pstring)-(strlen(codepage_file_name)+1), + sizeof(pstring)-(strlen(codepage_file_name)+1)-1, "%03d", client_codepage); diff --git a/source3/lib/messages.c b/source3/lib/messages.c index ab02d1253bf..5591f141cc1 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -115,7 +115,7 @@ static TDB_DATA message_key_pid(pid_t pid) static char key[20]; TDB_DATA kbuf; - slprintf(key, sizeof(key), "PID/%d", (int)pid); + slprintf(key, sizeof(key)-1, "PID/%d", (int)pid); kbuf.dptr = (char *)key; kbuf.dsize = strlen(key)+1; diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index c4bd1377c28..6abdeea114c 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -182,7 +182,7 @@ void standard_sub_basic(char *str) case 'T' : string_sub(p,"%T", timestring(False),l); break; case 'a' : string_sub(p,"%a", remote_arch,l); break; case 'd' : - slprintf(pidstr,sizeof(pidstr), "%d",(int)sys_getpid()); + slprintf(pidstr,sizeof(pidstr)-1, "%d",(int)sys_getpid()); string_sub(p,"%d", pidstr,l); break; case 'h' : string_sub(p,"%h", myhostname(),l); break; diff --git a/source3/lib/util.c b/source3/lib/util.c index 2b7cfabf8e5..439788bdac5 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1875,7 +1875,7 @@ int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6) char pidstr[10]; pstring cmd = "/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; gdb /proc/%d/exe %d'"; - slprintf(pidstr, sizeof(pidstr), "%d", sys_getpid()); + slprintf(pidstr, sizeof(pidstr)-1, "%d", sys_getpid()); pstring_sub(cmd, "%d", pidstr); if (!fn) { diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index e07e5ef6ada..03ad5a66b01 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1262,7 +1262,7 @@ char *octal_string(int i) if (i == -1) { return "-1"; } - slprintf(ret, sizeof(ret), "0%o", i); + slprintf(ret, sizeof(ret)-1, "0%o", i); return ret; } diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 3ab4bdca9f1..18f3b54bf71 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -1960,9 +1960,9 @@ smb_ucs2_t *octal_string_w(int i) char ret[64]; if (i == -1) - slprintf(ret, sizeof(ret), "-1"); + slprintf(ret, sizeof(ret)-1, "-1"); else - slprintf(ret, sizeof(ret), "0%o", i); + slprintf(ret, sizeof(ret)-1, "0%o", i); return unix_to_unicode(wret, ret, sizeof(wret)); } diff --git a/source3/libsmb/cli_spoolss.c b/source3/libsmb/cli_spoolss.c index b335127b8be..475ebf66a24 100644 --- a/source3/libsmb/cli_spoolss.c +++ b/source3/libsmb/cli_spoolss.c @@ -474,7 +474,7 @@ uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level, ZERO_STRUCT(q); ZERO_STRUCT(r); - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); do { @@ -701,7 +701,7 @@ uint32 cli_spoolss_enumprinterdrivers ( ZERO_STRUCT(q); ZERO_STRUCT(r); - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); do @@ -781,7 +781,7 @@ uint32 cli_spoolss_getprinterdriverdir ( ZERO_STRUCT(q); ZERO_STRUCT(r); - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); do @@ -848,7 +848,7 @@ uint32 cli_spoolss_addprinterdriver ( ZERO_STRUCT(q); ZERO_STRUCT(r); - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); /* Initialise input parameters */ @@ -899,9 +899,9 @@ uint32 cli_spoolss_addprinterex ( ZERO_STRUCT(q); ZERO_STRUCT(r); - slprintf (client, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (client, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (client); - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); fstrcpy (user, cli->user_name); diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 01ec5e9b29c..781bca7eff1 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1013,7 +1013,7 @@ NT GETDC call, UNICODE, NT domain SID and uncle tom cobbley and all... bufp += 2; fstrcpy(bufp,srcname); bufp += (strlen(bufp) + 1); - slprintf(bufp, sizeof(fstring), "\\MAILSLOT\\NET\\GETDC%d", dgm_id); + slprintf(bufp, sizeof(fstring)-1, "\\MAILSLOT\\NET\\GETDC%d", dgm_id); mailslot_name = bufp; bufp += (strlen(bufp) + 1); bufp = ALIGN2(bufp, buffer); diff --git a/source3/msdfs/msdfs.c b/source3/msdfs/msdfs.c index d525edab3cf..b93590fcd24 100644 --- a/source3/msdfs/msdfs.c +++ b/source3/msdfs/msdfs.c @@ -690,7 +690,7 @@ static BOOL form_junctions(int snum, struct junction_map* jn, int* jn_count) jn[cnt].volume_name[0] = '\0'; jn[cnt].referral_count = 1; - slprintf(alt_path,"\\\\%s\\%s", global_myname, service_name); + slprintf(alt_path,sizeof(alt_path)-1"\\\\%s\\%s", global_myname, service_name); jn[cnt].referral_l */ diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 5e8e7e1ec66..e176abbe6f1 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -672,7 +672,7 @@ static void usage(char *pname) TimeInit(); - slprintf(debugf, sizeof(debugf), "%s/log.nmbd", LOGFILEBASE); + slprintf(debugf, sizeof(debugf)-1, "%s/log.nmbd", LOGFILEBASE); setup_logging( argv[0], False ); charset_initialise(); diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c index 33b33040cb2..454b2170aa7 100644 --- a/source3/nmbd/nmbd_winsserver.c +++ b/source3/nmbd/nmbd_winsserver.c @@ -50,7 +50,7 @@ static void wins_hook(char *operation, struct name_record *namerec, int ttl) } p = command; - p += slprintf(p, sizeof(command), "%s %s %s %02x %d", + p += slprintf(p, sizeof(command)-1, "%s %s %s %02x %d", cmd, operation, namerec->name.name, @@ -58,7 +58,7 @@ static void wins_hook(char *operation, struct name_record *namerec, int ttl) ttl); for (i=0;idata.num_ips;i++) { - p += slprintf(p, sizeof(command) - (p-command), " %s", inet_ntoa(namerec->data.ip[i])); + p += slprintf(p, sizeof(command) - (p-command) -1, " %s", inet_ntoa(namerec->data.ip[i])); } DEBUG(3,("calling wins hook for %s\n", nmb_namestr(&namerec->name))); @@ -1597,9 +1597,9 @@ void wins_write_database(BOOL background) } } - slprintf(fname,sizeof(fname),"%s/%s", lp_lockdir(), WINS_LIST); + slprintf(fname,sizeof(fname)-1,"%s/%s", lp_lockdir(), WINS_LIST); all_string_sub(fname,"//", "/", 0); - slprintf(fnamenew,sizeof(fnamenew),"%s.%u", fname, (unsigned int)sys_getpid()); + slprintf(fnamenew,sizeof(fnamenew)-1,"%s.%u", fname, (unsigned int)sys_getpid()); if((fp = sys_fopen(fnamenew,"w")) == NULL) { diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 7af1d09723b..b0e35f3cd6e 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -82,7 +82,7 @@ static void termination_handler(int signum) /* Remove socket file */ - slprintf(path, sizeof(path), "%s/%s", + slprintf(path, sizeof(path)-1, "%s/%s", WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME); unlink(path); @@ -159,7 +159,7 @@ static int create_sock(void) return -1; } - slprintf(path, sizeof(path), "%s/%s", + slprintf(path, sizeof(path)-1, "%s/%s", WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME); unlink(path); @@ -587,7 +587,7 @@ int main(int argc, char **argv) } /* Initialise samba/rpc client stuff */ - slprintf(debugf, sizeof(debugf), "%s/log.winbindd", LOGFILEBASE); + slprintf(debugf, sizeof(debugf)-1, "%s/log.winbindd", LOGFILEBASE); setup_logging("winbindd", interactive); reopen_logs(); diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c index 226a96b9b50..7b263dfe009 100644 --- a/source3/nsswitch/winbindd_cache.c +++ b/source3/nsswitch/winbindd_cache.c @@ -55,7 +55,7 @@ static uint32 cached_sequence_number(char *domain_name) struct cache_rec rec; time_t t = time(NULL); - slprintf(keystr, sizeof(keystr), "CACHESEQ/%s", domain_name); + slprintf(keystr, sizeof(keystr)-1, "CACHESEQ/%s", domain_name); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ dbuf = tdb_fetch_by_string(cache_tdb, keystr); if (!dbuf.dptr || dbuf.dsize != sizeof(rec)) { @@ -91,7 +91,7 @@ static BOOL cache_domain_expired(char *domain_name, uint32 seq_num) static void set_cache_sequence_number(char *domain_name, char *cache_type, char *subkey) { fstring keystr; - slprintf(keystr,sizeof(keystr),"CACHESEQ %s/%s/%s", + slprintf(keystr,sizeof(keystr)-1,"CACHESEQ %s/%s/%s", domain_name, cache_type, subkey?subkey:""); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ tdb_store_int(cache_tdb, keystr, cached_sequence_number(domain_name)); @@ -101,7 +101,7 @@ static uint32 get_cache_sequence_number(char *domain_name, char *cache_type, cha { fstring keystr; uint32 seq_num; - slprintf(keystr,sizeof(keystr),"CACHESEQ %s/%s/%s", + slprintf(keystr,sizeof(keystr)-1,"CACHESEQ %s/%s/%s", domain_name, cache_type, subkey?subkey:""); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ seq_num = (uint32)tdb_fetch_int(cache_tdb, keystr); @@ -125,7 +125,7 @@ static void fill_cache(char *domain_name, char *cache_type, cache_type, domain_name, num_sam_entries)); /* Store data as a mega-huge chunk in the tdb */ - slprintf(keystr, sizeof(keystr), "%s CACHE DATA/%s", cache_type, + slprintf(keystr, sizeof(keystr)-1, "%s CACHE DATA/%s", cache_type, domain_name); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ tdb_store_by_string(cache_tdb, keystr, @@ -158,7 +158,7 @@ static void fill_cache_entry(char *domain, char *cache_type, char *name, void *b fstring keystr; /* Create key for store */ - slprintf(keystr, sizeof(keystr), "%s/%s/%s", cache_type, domain, name); + slprintf(keystr, sizeof(keystr)-1, "%s/%s/%s", cache_type, domain, name); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ DEBUG(4, ("filling cache entry %s\n", keystr)); @@ -185,7 +185,7 @@ void winbindd_fill_uid_cache_entry(char *domain, uid_t uid, if (lp_winbind_cache_time() == 0) return; - slprintf(uidstr, sizeof(uidstr), "#%u", (unsigned)uid); + slprintf(uidstr, sizeof(uidstr)-1, "#%u", (unsigned)uid); fill_cache_entry(domain, CACHE_TYPE_USER, uidstr, pw, sizeof(struct winbindd_pw)); set_cache_sequence_number(domain, CACHE_TYPE_USER, uidstr); } @@ -203,7 +203,7 @@ void winbindd_fill_group_cache_entry(char *domain, char *group_name, fill_cache_entry(domain, CACHE_TYPE_GROUP, group_name, gr, sizeof(struct winbindd_gr)); /* Fill extra data */ - slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain, group_name); + slprintf(keystr, sizeof(keystr)-1, "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain, group_name); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ tdb_store_by_string(cache_tdb, keystr, extra_data, extra_data_len); @@ -218,7 +218,7 @@ void winbindd_fill_gid_cache_entry(char *domain, gid_t gid, fstring keystr; fstring gidstr; - slprintf(gidstr, sizeof(gidstr), "#%u", (unsigned)gid); + slprintf(gidstr, sizeof(gidstr)-1, "#%u", (unsigned)gid); if (lp_winbind_cache_time() == 0) return; @@ -226,7 +226,7 @@ void winbindd_fill_gid_cache_entry(char *domain, gid_t gid, fill_cache_entry(domain, CACHE_TYPE_GROUP, gidstr, gr, sizeof(struct winbindd_gr)); /* Fill extra data */ - slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain, gidstr); + slprintf(keystr, sizeof(keystr)-1, "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain, gidstr); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ tdb_store_by_string(cache_tdb, keystr, extra_data, extra_data_len); @@ -254,7 +254,7 @@ static BOOL fetch_cache(char *domain_name, char *cache_type, } /* Create key */ - slprintf(keystr, sizeof(keystr), "%s CACHE DATA/%s", cache_type, + slprintf(keystr, sizeof(keystr)-1, "%s CACHE DATA/%s", cache_type, domain_name); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ @@ -304,7 +304,7 @@ static BOOL fetch_cache_entry(char *domain, char *cache_type, char *name, void * fstring keystr; /* Create key for lookup */ - slprintf(keystr, sizeof(keystr), "%s/%s/%s", cache_type, domain, name); + slprintf(keystr, sizeof(keystr)-1, "%s/%s/%s", cache_type, domain, name); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ /* Look up cache entry */ @@ -342,7 +342,7 @@ BOOL winbindd_fetch_uid_cache_entry(char *domain_name, uid_t uid, if (lp_winbind_cache_time() == 0) return False; - slprintf(uidstr, sizeof(uidstr), "#%u", (unsigned)uid); + slprintf(uidstr, sizeof(uidstr)-1, "#%u", (unsigned)uid); seq_num = get_cache_sequence_number(domain_name, CACHE_TYPE_USER, uidstr); if (cache_domain_expired(domain_name, seq_num)) return False; @@ -369,7 +369,7 @@ BOOL winbindd_fetch_group_cache_entry(char *domain_name, char *group, if (!fetch_cache_entry(domain_name, CACHE_TYPE_GROUP, group, gr, sizeof(struct winbindd_gr))) return False; /* Fetch extra data */ - slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain_name, group); + slprintf(keystr, sizeof(keystr)-1, "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain_name, group); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ data = tdb_fetch_by_string(cache_tdb, keystr); @@ -395,7 +395,7 @@ BOOL winbindd_fetch_gid_cache_entry(char *domain_name, gid_t gid, fstring gidstr; uint32 seq_num; - slprintf(gidstr, sizeof(gidstr), "#%u", (unsigned)gid); + slprintf(gidstr, sizeof(gidstr)-1, "#%u", (unsigned)gid); if (lp_winbind_cache_time() == 0) return False; @@ -407,7 +407,7 @@ BOOL winbindd_fetch_gid_cache_entry(char *domain_name, gid_t gid, gidstr, gr, sizeof(struct winbindd_gr))) return False; /* Fetch extra data */ - slprintf(keystr, sizeof(keystr), "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain_name, gidstr); + slprintf(keystr, sizeof(keystr)-1, "%s/%s/%s DATA", CACHE_TYPE_GROUP, domain_name, gidstr); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ data = tdb_fetch_by_string(cache_tdb, keystr); if (!data.dptr) return False; diff --git a/source3/nsswitch/winbindd_group.c b/source3/nsswitch/winbindd_group.c index e96947b7e65..77825cd5798 100644 --- a/source3/nsswitch/winbindd_group.c +++ b/source3/nsswitch/winbindd_group.c @@ -270,7 +270,7 @@ static BOOL winbindd_fill_grent_mem(struct winbindd_domain *domain, malloc(sizeof(*entry))) != NULL) { /* Create name */ - slprintf(entry->name, sizeof(entry->name), + slprintf(entry->name, sizeof(entry->name)-1, "%s%s%s", name_dom, lp_winbind_separator(), name_user); /* Add to list */ @@ -477,7 +477,7 @@ enum winbindd_result winbindd_getgrnam_from_group(struct winbindd_cli_state *sta return WINBINDD_OK; } - slprintf(name, sizeof(name), "%s\\%s", name_domain, name_group); + slprintf(name, sizeof(name)-1, "%s\\%s", name_domain, name_group); /* Get rid and name type from name */ @@ -717,7 +717,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state) /* Prepend domain to name */ - slprintf(domain_group_name, sizeof(domain_group_name), + slprintf(domain_group_name, sizeof(domain_group_name)-1, "%s%s%s", ent->domain->name, lp_winbind_separator(), group_name); /* Get group entry from group name */ diff --git a/source3/nsswitch/winbindd_idmap.c b/source3/nsswitch/winbindd_idmap.c index ff0818c4565..11f7b8aae7a 100644 --- a/source3/nsswitch/winbindd_idmap.c +++ b/source3/nsswitch/winbindd_idmap.c @@ -77,7 +77,7 @@ static BOOL get_id_from_rid(char *domain_name, uint32 rid, int *id, /* Check if rid is present in database */ - slprintf(keystr, sizeof(keystr), "%s/%d", domain_name, rid); + slprintf(keystr, sizeof(keystr)-1, "%s/%d", domain_name, rid); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ key.dptr = keystr; @@ -116,7 +116,7 @@ static BOOL get_id_from_rid(char *domain_name, uint32 rid, int *id, /* Store new id */ - slprintf(keystr2, sizeof(keystr2), "%s %d", isgroup ? "GID" : + slprintf(keystr2, sizeof(keystr2)-1, "%s %d", isgroup ? "GID" : "UID", *id); data.dptr = keystr2; @@ -155,7 +155,7 @@ BOOL get_rid_from_id(int id, uint32 *rid, struct winbindd_domain **domain, fstring keystr; BOOL result = False; - slprintf(keystr, sizeof(keystr), "%s %d", isgroup ? "GID" : "UID", id); + slprintf(keystr, sizeof(keystr)-1, "%s %d", isgroup ? "GID" : "UID", id); key.dptr = keystr; key.dsize = strlen(keystr) + 1; diff --git a/source3/nsswitch/winbindd_pam.c b/source3/nsswitch/winbindd_pam.c index 48a1a829ebc..c74afd8e291 100644 --- a/source3/nsswitch/winbindd_pam.c +++ b/source3/nsswitch/winbindd_pam.c @@ -55,7 +55,7 @@ enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state) nt_lm_owf_gen(state->request.data.auth.pass, ntpw, lmpw); - slprintf(server, sizeof(server), "\\\\%s", server_state.controller); + slprintf(server, sizeof(server)-1, "\\\\%s", server_state.controller); status = domain_client_validate_backend(server, name_user, name_domain, diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c index 9a73b0107b0..f3e62d2f7f1 100644 --- a/source3/nsswitch/winbindd_user.c +++ b/source3/nsswitch/winbindd_user.c @@ -106,7 +106,7 @@ enum winbindd_result winbindd_getpwnam_from_user(struct winbindd_cli_state *stat return WINBINDD_OK; } - slprintf(name,sizeof(name),"%s\\%s", name_domain, name_user); + slprintf(name,sizeof(name)-1,"%s\\%s", name_domain, name_user); /* Get rid and name type from name */ /* the following costs 1 packet */ @@ -364,7 +364,7 @@ enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state) /* Prepend domain to name */ - slprintf(domain_user_name, sizeof(domain_user_name), + slprintf(domain_user_name, sizeof(domain_user_name)-1, "%s%s%s", ent->domain->name, lp_winbind_separator(), user_name); /* Get passwd entry from user name */ diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index bfa1ed98cad..a3b49cd5916 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -88,7 +88,7 @@ BOOL secrets_store_domain_sid(char *domain, DOM_SID *sid) { fstring key; - slprintf(key, sizeof(key), "%s/%s", SECRETS_DOMAIN_SID, domain); + slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_SID, domain); return secrets_store(key, sid, sizeof(DOM_SID)); } @@ -98,7 +98,7 @@ BOOL secrets_fetch_domain_sid(char *domain, DOM_SID *sid) fstring key; size_t size; - slprintf(key, sizeof(key), "%s/%s", SECRETS_DOMAIN_SID, domain); + slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_SID, domain); dos_to_unix(key, True); /* Convert key to unix-codepage */ dyn_sid = (DOM_SID *)secrets_fetch(key, &size); @@ -128,7 +128,7 @@ char *trust_keystr(char *domain) fstrcpy(dos_domain, domain); unix_to_dos(dos_domain, True); - slprintf(keystr,sizeof(keystr),"%s/%s", + slprintf(keystr,sizeof(keystr)-1,"%s/%s", SECRETS_MACHINE_ACCT_PASS, dos_domain); return keystr; diff --git a/source3/printing/printing.c b/source3/printing/printing.c index e886bd75a2c..753d0f7f966 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -254,7 +254,7 @@ check if the print queue has been updated recently enough static void print_cache_flush(int snum) { fstring key; - slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum)); + slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum)); dos_to_unix(key, True); /* Convert key to unix-codepage */ tdb_store_int(tdb, key, -1); } @@ -269,7 +269,7 @@ static pid_t get_updating_pid(fstring printer_name) TDB_DATA data, key; pid_t updating_pid; - slprintf(keystr, sizeof(keystr), "UPDATING/%s", printer_name); + slprintf(keystr, sizeof(keystr)-1, "UPDATING/%s", printer_name); key.dptr = keystr; key.dsize = strlen(keystr); @@ -298,7 +298,7 @@ static void set_updating_pid(fstring printer_name, BOOL delete) TDB_DATA data; pid_t updating_pid = getpid(); - slprintf(keystr, sizeof(keystr), "UPDATING/%s", printer_name); + slprintf(keystr, sizeof(keystr)-1, "UPDATING/%s", printer_name); key.dptr = keystr; key.dsize = strlen(keystr); @@ -380,7 +380,7 @@ static void print_queue_update(int snum) * if the lpq takes a long time. */ - slprintf(cachestr, sizeof(cachestr), "CACHE/%s", printer_name); + slprintf(cachestr, sizeof(cachestr)-1, "CACHE/%s", printer_name); tdb_store_int(tdb, cachestr, (int)time(NULL)); /* get the current queue using the appropriate interface */ @@ -452,7 +452,7 @@ static void print_queue_update(int snum) } /* store the new queue status structure */ - slprintf(keystr, sizeof(keystr), "STATUS/%s", printer_name); + slprintf(keystr, sizeof(keystr)-1, "STATUS/%s", printer_name); key.dptr = keystr; key.dsize = strlen(keystr); @@ -466,7 +466,7 @@ static void print_queue_update(int snum) * as little as possible... */ - slprintf(keystr, sizeof(keystr), "CACHE/%s", printer_name); + slprintf(keystr, sizeof(keystr)-1, "CACHE/%s", printer_name); tdb_store_int(tdb, keystr, (int)time(NULL)); /* Delete our pid from the db. */ @@ -751,7 +751,7 @@ static BOOL print_cache_expired(int snum) fstring key; time_t t2, t = time(NULL); - slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum)); + slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum)); dos_to_unix(key, True); /* Convert key to unix-codepage */ t2 = tdb_fetch_int(tdb, key); if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) { @@ -770,7 +770,7 @@ static int get_queue_status(int snum, print_status_struct *status) TDB_DATA data, key; ZERO_STRUCTP(status); - slprintf(keystr, sizeof(keystr), "STATUS/%s", lp_servicename(snum)); + slprintf(keystr, sizeof(keystr)-1, "STATUS/%s", lp_servicename(snum)); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ key.dptr = keystr; key.dsize = strlen(keystr); @@ -912,7 +912,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname) a symlink security hole - it allows us to use O_EXCL There may be old spool files owned by other users lying around. */ - slprintf(pjob.filename, sizeof(pjob.filename), "%s/%s%d", + slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%d", path, PRINT_SPOOL_PREFIX, jobid); if (unlink(pjob.filename) == -1 && errno != ENOENT) { goto next_jobnum; @@ -1120,7 +1120,7 @@ int print_queue_status(int snum, * be no jobs in the queue. */ ZERO_STRUCTP(status); - slprintf(keystr, sizeof(keystr), "STATUS/%s", lp_servicename(snum)); + slprintf(keystr, sizeof(keystr)-1, "STATUS/%s", lp_servicename(snum)); dos_to_unix(keystr, True); /* Convert key to unix-codepage */ key.dptr = keystr; key.dsize = strlen(keystr); diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c index 8311528874f..6bab18ba9d7 100644 --- a/source3/rpc_parse/parse_prs.c +++ b/source3/rpc_parse/parse_prs.c @@ -36,9 +36,9 @@ void prs_dump(char *name, int v, prs_struct *ps) if (DEBUGLEVEL < 50) return; for (i=1;i<100;i++) { if (v != -1) { - slprintf(fname,sizeof(fname), "/tmp/%s_%d.%d.prs", name, v, i); + slprintf(fname,sizeof(fname)-1, "/tmp/%s_%d.%d.prs", name, v, i); } else { - slprintf(fname,sizeof(fname), "/tmp/%s.%d.prs", name, i); + slprintf(fname,sizeof(fname)-1, "/tmp/%s.%d.prs", name, i); } fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644); if (fd != -1 || errno != EEXIST) break; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 32ec81b07ad..0654f24493a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1171,7 +1171,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, /* interpret the command */ DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); - slprintf(name, sizeof(name), "in_%s", rpc_name); + slprintf(name, sizeof(name)-1, "in_%s", rpc_name); prs_dump(name, p->hdr_req.opnum, &p->in_data.data); for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { @@ -1201,7 +1201,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, return False; } - slprintf(name, sizeof(name), "out_%s", rpc_name); + slprintf(name, sizeof(name)-1, "out_%s", rpc_name); offset2 = prs_offset(&p->out_data.rdata); prs_set_offset(&p->out_data.rdata, offset1); prs_dump(name, p->hdr_req.opnum, &p->out_data.rdata); diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index ca9469aede0..b3d135275a7 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -120,7 +120,7 @@ static uint32 cmd_samr_query_user(struct cli_state *cli, int argc, char **argv) return NT_STATUS_UNSUCCESSFUL; } - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); if ((result = cli_samr_connect(cli, server, MAXIMUM_ALLOWED_ACCESS, @@ -239,7 +239,7 @@ static uint32 cmd_samr_query_group(struct cli_state *cli, int argc, char **argv) return NT_STATUS_UNSUCCESSFUL; } - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); if ((result = cli_samr_connect(cli, server, MAXIMUM_ALLOWED_ACCESS, @@ -319,7 +319,7 @@ static uint32 cmd_samr_query_usergroups(struct cli_state *cli, int argc, char ** return NT_STATUS_UNSUCCESSFUL; } - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); if ((result = cli_samr_connect(cli, server, MAXIMUM_ALLOWED_ACCESS, @@ -396,7 +396,7 @@ static uint32 cmd_samr_query_groupmem(struct cli_state *cli, int argc, char **ar return NT_STATUS_UNSUCCESSFUL; } - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); if ((result = cli_samr_connect(cli, server, MAXIMUM_ALLOWED_ACCESS, diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 0b45767afe1..157abb27f51 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -158,7 +158,7 @@ static uint32 cmd_spoolss_open_printer_ex(struct cli_state *cli, int argc, char return NT_STATUS_UNSUCCESSFUL; - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); fstrcpy (user, cli->user_name); fstrcpy (printername, argv[1]); @@ -503,9 +503,9 @@ static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **arg info_level = atoi(argv[2]); } - slprintf (servername, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (servername); - slprintf (printername, sizeof(fstring), "\\\\%s\\%s", servername, argv[1]); + slprintf (printername, sizeof(fstring)-1, "\\\\%s\\%s", servername, argv[1]); fstrcpy (username, cli->user_name); /* get a printer handle */ @@ -691,7 +691,7 @@ static uint32 cmd_spoolss_getdriver(struct cli_state *cli, int argc, char **argv } /* get the arguments need to open the printer handle */ - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); fstrcpy (user, cli->user_name); fstrcpy (printername, argv[1]); @@ -789,7 +789,7 @@ static uint32 cmd_spoolss_enum_drivers(struct cli_state *cli, int argc, char **a } /* get the arguments need to open the printer handle */ - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); if (argc == 2) info_level = atoi(argv[1]); @@ -1091,7 +1091,7 @@ static uint32 cmd_spoolss_addprinterex (struct cli_state *cli, int argc, char ** return NT_STATUS_NOPROBLEMO; } - slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost); + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); strupper (server); /* Initialise RPC connection */ diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 8ab4e0c5d3f..125b2fbbe54 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -434,7 +434,7 @@ static int utmp_fill(struct utmp *u, const connection_struct *conn, pid_t pid, * o with overflow if ut_line would be more than full. */ memset(line_tmp, '\0', sizeof(line_tmp)); - slprintf(line_tmp, sizeof(line_tmp), (char *) ut_line_template, i); + slprintf(line_tmp, sizeof(line_tmp)-1, (char *) ut_line_template, i); line_len = strlen(line_tmp); if (line_len <= sizeof(u->ut_line)) { memcpy(u->ut_line, line_tmp, sizeof(u->ut_line)); diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index c523f2cab4b..64c6182cd8d 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -88,7 +88,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, char **lines; pstring syscmd; - slprintf(syscmd, sizeof(syscmd), "%s %s", dfree_command, path); + slprintf(syscmd, sizeof(syscmd)-1, "%s %s", dfree_command, path); DEBUG (3, ("disk_free: Running command %s\n", syscmd)); lines = file_lines_pload(syscmd, NULL, True); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index dea7130cfed..ac5454c48c8 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -592,7 +592,7 @@ static void smb_dump(char *name, int type, char *data, ssize_t len) if (len < 4) len = smb_len(data)+4; for (i=1;i<100;i++) { - slprintf(fname,sizeof(fname), "/tmp/%s.%d.%s", name, i, + slprintf(fname,sizeof(fname)-1, "/tmp/%s.%d.%s", name, i, type ? "req" : "resp"); fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644); if (fd != -1 || errno != EEXIST) break; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 35a4b0f54ab..4176dd01040 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -880,7 +880,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int if (!sys_getpwnam(user)) { pstring user2; - slprintf(user2,sizeof(user2),"%s%s%s", dos_to_unix(domain,False), + slprintf(user2,sizeof(user2)-1,"%s%s%s", dos_to_unix(domain,False), lp_winbind_separator(), user); if (sys_getpwnam(user2)) { diff --git a/source3/smbd/server.c b/source3/smbd/server.c index baa1536248a..adf57b3f552 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -626,7 +626,7 @@ static void usage(char *pname) TimeInit(); if(!specified_logfile) { - slprintf(debugf, sizeof(debugf), "%s/log.smbd", LOGFILEBASE); + slprintf(debugf, sizeof(debugf)-1, "%s/log.smbd", LOGFILEBASE); } pstrcpy(remote_machine, "smbd"); -- 2.34.1