From f9a15ce1a69f905e94db7650f0a4805720cd9c88 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 8 Apr 2001 20:22:39 +0000 Subject: Got "medieval on our ass" about adding the -1 to slprintf. Jeremy. (This used to be commit 94747b4639ed9b19f7d0fb896e43aa392a84989a) --- 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 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) (limited to 'source3/nsswitch') diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 7af1d09723..b0e35f3cd6 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 226a96b9b5..7b263dfe00 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 e96947b7e6..77825cd579 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 ff0818c456..11f7b8aae7 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 48a1a829eb..c74afd8e29 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 9a73b0107b..f3e62d2f7f 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 */ -- cgit