diff options
author | Volker Lendecke <vl@sernet.de> | 2007-11-24 15:47:04 +0100 |
---|---|---|
committer | Volker Lendecke <vl@sernet.de> | 2007-12-05 14:39:07 +0100 |
commit | 195d6be38d9d721837a8d44ff918829528059cda (patch) | |
tree | 5a7fb32b88a656927e2e2a4b699d135b22e77612 /source3 | |
parent | 78c6ee0090f4122bc25baaacb5546517ad4b7bc6 (diff) | |
download | samba-195d6be38d9d721837a8d44ff918829528059cda.tar.gz samba-195d6be38d9d721837a8d44ff918829528059cda.tar.bz2 samba-195d6be38d9d721837a8d44ff918829528059cda.zip |
remove some statics
(This used to be commit 97c9a4042d36178a728b5e0f8923091c7069366d)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/credentials.c | 12 | ||||
-rw-r--r-- | source3/libsmb/nmblib.c | 49 | ||||
-rw-r--r-- | source3/libsmb/unexpected.c | 43 | ||||
-rw-r--r-- | source3/torture/rpctorture.c | 34 |
4 files changed, 72 insertions, 66 deletions
diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index 973bb6ad28..1256a6210e 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -26,11 +26,13 @@ char *credstr(const unsigned char *cred) { - static fstring buf; - slprintf(buf, sizeof(buf) - 1, "%02X%02X%02X%02X%02X%02X%02X%02X", - cred[0], cred[1], cred[2], cred[3], - cred[4], cred[5], cred[6], cred[7]); - return buf; + char *result; + result = talloc_asprintf(talloc_tos(), + "%02X%02X%02X%02X%02X%02X%02X%02X", + cred[0], cred[1], cred[2], cred[3], + cred[4], cred[5], cred[6], cred[7]); + SMB_ASSERT(result != NULL); + return result; } /**************************************************************************** diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index 7e152ab324..2ff925ef36 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -347,20 +347,19 @@ static int put_nmb_name(char *buf,int offset,struct nmb_name *name) char *nmb_namestr(const struct nmb_name *n) { - static int i=0; - static fstring ret[4]; fstring name; - char *p = ret[i]; + char *result; pull_ascii_fstring(name, n->name); if (!n->scope[0]) - slprintf(p,sizeof(fstring)-1, "%s<%02x>",name,n->name_type); + result = talloc_asprintf(talloc_tos(), "%s<%02x>", name, + n->name_type); else - slprintf(p,sizeof(fstring)-1, "%s<%02x>.%s", - name,n->name_type,n->scope); + result = talloc_asprintf(talloc_tos(), "%s<%02x>.%s", name, + n->name_type, n->scope); - i = (i+1)%4; - return(p); + SMB_ASSERT(result != NULL); + return result; } /******************************************************************* @@ -1239,40 +1238,6 @@ void sort_query_replies(char *data, int n, struct in_addr ip) qsort(data, n, 6, QSORT_CAST name_query_comp); } -/******************************************************************* - Convert, possibly using a stupid microsoft-ism which has destroyed - the transport independence of netbios (for CIFS vendors that usually - use the Win95-type methods, not for NT to NT communication, which uses - DCE/RPC and therefore full-length unicode strings...) a dns name into - a netbios name. - - The netbios name (NOT necessarily null-terminated) is truncated to 15 - characters. - - ******************************************************************/ - -char *dns_to_netbios_name(const char *dns_name) -{ - static nstring netbios_name; - int i; - StrnCpy(netbios_name, dns_name, MAX_NETBIOSNAME_LEN-1); - netbios_name[15] = 0; - - /* ok. this is because of a stupid microsoft-ism. if the called host - name contains a '.', microsoft clients expect you to truncate the - netbios name up to and including the '.' this even applies, by - mistake, to workgroup (domain) names, which is _really_ daft. - */ - for (i = 0; i < 15; i++) { - if (netbios_name[i] == '.') { - netbios_name[i] = 0; - break; - } - } - - return netbios_name; -} - /**************************************************************************** Interpret the weird netbios "name" into a unix fstring. Return the name type. ****************************************************************************/ diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c index f5837f321c..92a609c42b 100644 --- a/source3/libsmb/unexpected.c +++ b/source3/libsmb/unexpected.c @@ -112,18 +112,22 @@ void clear_unexpected(time_t t) tdb_traverse(tdbd, traverse_fn, NULL); } - -static struct packet_struct *matched_packet; -static int match_id; -static enum packet_type match_type; -static const char *match_name; +struct receive_unexpected_state { + struct packet_struct *matched_packet; + int match_id; + enum packet_type match_type; + const char *match_name; +}; /**************************************************************************** tdb traversal fn to find a matching 137 packet. **************************************************************************/ -static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state) +static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, + void *private_data) { + struct receive_unexpected_state *state = + (struct receive_unexpected_state *)private_data; struct unexpected_key key; struct in_addr ip; uint32_t enc_ip; @@ -132,7 +136,7 @@ static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void memcpy(&key, kbuf.dptr, sizeof(key)); - if (key.packet_type != match_type) return 0; + if (key.packet_type != state->match_type) return 0; if (dbuf.dsize < 6) { return 0; @@ -145,15 +149,15 @@ static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void p = parse_packet((char *)&dbuf.dptr[6], dbuf.dsize-6, - match_type, + state->match_type, ip, port); - if ((match_type == NMB_PACKET && - p->packet.nmb.header.name_trn_id == match_id) || - (match_type == DGRAM_PACKET && - match_mailslot_name(p, match_name))) { - matched_packet = p; + if ((state->match_type == NMB_PACKET && + p->packet.nmb.header.name_trn_id == state->match_id) || + (state->match_type == DGRAM_PACKET && + match_mailslot_name(p, state->match_name))) { + state->matched_packet = p; return -1; } @@ -170,18 +174,19 @@ struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, const char *mailslot_name) { TDB_CONTEXT *tdb2; + struct receive_unexpected_state state; tdb2 = tdb_open_log(lock_path("unexpected.tdb"), 0, 0, O_RDONLY, 0); if (!tdb2) return NULL; - matched_packet = NULL; - match_id = id; - match_type = packet_type; - match_name = mailslot_name; + state.matched_packet = NULL; + state.match_id = id; + state.match_type = packet_type; + state.match_name = mailslot_name; - tdb_traverse(tdb2, traverse_match, NULL); + tdb_traverse(tdb2, traverse_match, &state); tdb_close(tdb2); - return matched_packet; + return state.matched_packet; } diff --git a/source3/torture/rpctorture.c b/source3/torture/rpctorture.c index d399ae8a0f..8db58014b7 100644 --- a/source3/torture/rpctorture.c +++ b/source3/torture/rpctorture.c @@ -45,6 +45,40 @@ void rpcclient_init(void) smb_cli->capabilities |= CAP_NT_SMBS; } +/******************************************************************* + Convert, possibly using a stupid microsoft-ism which has destroyed + the transport independence of netbios (for CIFS vendors that usually + use the Win95-type methods, not for NT to NT communication, which uses + DCE/RPC and therefore full-length unicode strings...) a dns name into + a netbios name. + + The netbios name (NOT necessarily null-terminated) is truncated to 15 + characters. + + ******************************************************************/ + +static char *dns_to_netbios_name(const char *dns_name) +{ + static nstring netbios_name; + int i; + StrnCpy(netbios_name, dns_name, MAX_NETBIOSNAME_LEN-1); + netbios_name[15] = 0; + + /* ok. this is because of a stupid microsoft-ism. if the called host + name contains a '.', microsoft clients expect you to truncate the + netbios name up to and including the '.' this even applies, by + mistake, to workgroup (domain) names, which is _really_ daft. + */ + for (i = 0; i < 15; i++) { + if (netbios_name[i] == '.') { + netbios_name[i] = 0; + break; + } + } + + return netbios_name; +} + /**************************************************************************** make smb client connection ****************************************************************************/ |