From acb829ecc3b9af3f141425ecac032a7c722a1815 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Nov 2007 18:27:26 -0800 Subject: Add MAX_DNS_NAME_LENGTH, remove more pstrings. Jeremy. (This used to be commit a1725f4ff7ed375808c78ac661b539557748d0a5) --- source3/locking/locking.c | 18 +++++++++--------- source3/locking/posix.c | 7 +++++-- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index aae297e031..8d511e9d8f 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -444,11 +444,9 @@ static TDB_DATA locking_key(struct file_id id) Print out a share mode. ********************************************************************/ -char *share_mode_str(int num, struct share_mode_entry *e) +char *share_mode_str(TALLOC_CTX *ctx, int num, struct share_mode_entry *e) { - static pstring share_str; - - slprintf(share_str, sizeof(share_str)-1, "share_mode_entry[%d]: %s " + return talloc_asprintf(ctx, "share_mode_entry[%d]: %s " "pid = %s, share_access = 0x%x, private_options = 0x%x, " "access_mask = 0x%x, mid = 0x%x, type= 0x%x, gen_id = %lu, " "uid = %u, flags = %u, file_id %s", @@ -459,8 +457,6 @@ char *share_mode_str(int num, struct share_mode_entry *e) e->access_mask, e->op_mid, e->op_type, e->share_file_id, (unsigned int)e->uid, (unsigned int)e->flags, file_id_string_tos(&e->id)); - - return share_str; } /******************************************************************* @@ -476,10 +472,12 @@ static void print_share_mode_table(struct locking_data *data) for (i = 0; i < num_share_modes; i++) { struct share_mode_entry entry; + char *str = share_mode_str(NULL, i, &entry); memcpy(&entry, &shares[i], sizeof(struct share_mode_entry)); DEBUG(10,("print_share_mode_table: %s\n", - share_mode_str(i, &entry))); + str ? str : "")); + TALLOC_FREE(str); } } @@ -603,14 +601,16 @@ static bool parse_share_modes(TDB_DATA dbuf, struct share_mode_lock *lck) for (i = 0; i < lck->num_share_modes; i++) { struct share_mode_entry *entry_p = &lck->share_modes[i]; + char *str = share_mode_str(NULL, i, entry_p); DEBUG(10,("parse_share_modes: %s\n", - share_mode_str(i, entry_p) )); + str ? str : "")); if (!process_exists(entry_p->pid)) { DEBUG(10,("parse_share_modes: deleted %s\n", - share_mode_str(i, entry_p) )); + str ? str : "")); entry_p->op_type = UNUSED_SHARE_MODE_ENTRY; lck->modified = True; } + TALLOC_FREE(str); } return True; diff --git a/source3/locking/posix.c b/source3/locking/posix.c index 135e204f01..37cfa04373 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -933,9 +933,12 @@ new: start=%.0f,size=%.0f\n", (double)l_curr->start, (double)l_curr->size, * This logic case should never happen. Ensure this is the * case by forcing an abort.... Remove in production. */ - pstring msg; + char *msg = NULL; - slprintf(msg, sizeof(msg)-1, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \ + /* Don't check if alloc succeeds here - we're + * forcing a core dump anyway. */ + + asprintf(&msg, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \ lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size ); smb_panic(msg); -- cgit