From a38e5e6850220fc1a0afa5097359c05458e1ae41 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 13:06:52 +0000 Subject: Small clenaup patches: - safe_string.h - don't assume that __FUNCTION__ is available - process.c - use new workaround from safe_string.h for the same - util.c - Show how many bytes we smb_panic()ed trying to smb_xmalloc() - gencache.c - Keep valgrind quiet by always null terminating. - clistr.c - Add copyright - srvstr.h - move srvstr_push into a .c file again, as a real function. - srvstr.c - revive, with 'safe' checked srvstr_push - loadparm.c - set a default for the display charset. Andrew Bartlett (This used to be commit a7eba37aadeb0b04cb1bd89deddb58be8aba825c) --- source3/smbd/connection.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'source3/smbd/connection.c') diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index a7636e889e..ff6974cade 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -35,15 +35,12 @@ TDB_CONTEXT *conn_tdb_ctx(void) return tdb; } -static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, struct connections_key *pkey) +static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, fstring tdb_key) { - ZERO_STRUCTP(pkey); - pkey->pid = sys_getpid(); - pkey->cnum = conn?conn->cnum:-1; - fstrcpy(pkey->name, name); + snprintf(tdb_key, sizeof(fstring), "CONN/%lu/%ld", sys_getpid(), conn?conn->cnum:-1); - pkbuf->dptr = (char *)pkey; - pkbuf->dsize = sizeof(*pkey); + pkbuf->dptr = tdb_key; + pkbuf->dsize = strlen(tdb_key)+1; } /**************************************************************************** @@ -52,7 +49,7 @@ static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *p BOOL yield_connection(connection_struct *conn, const char *name) { - struct connections_key key; + fstring tdb_key; TDB_DATA kbuf; if (!tdb) @@ -60,7 +57,7 @@ BOOL yield_connection(connection_struct *conn, const char *name) DEBUG(3,("Yielding connection to %s\n",name)); - make_conn_key(conn, name, &kbuf, &key); + make_conn_key(conn, name, &kbuf, tdb_key); if (tdb_delete(tdb, kbuf) != 0) { int dbg_lvl = (!conn && (tdb_error(tdb) == TDB_ERR_NOEXIST)) ? 3 : 0; @@ -171,14 +168,14 @@ BOOL claim_connection(connection_struct *conn, const char *name,int max_connecti if (conn) { crec.uid = conn->uid; crec.gid = conn->gid; - StrnCpy(crec.name, - lp_servicename(SNUM(conn)),sizeof(crec.name)-1); + safe_strcpy(crec.name, + lp_servicename(SNUM(conn)),sizeof(crec.name)-1); } crec.start = time(NULL); crec.bcast_msg_flags = msg_flags; - StrnCpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1); - StrnCpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1); + safe_strcpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1); + safe_strcpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1); dbuf.dptr = (char *)&crec; dbuf.dsize = sizeof(crec); -- cgit