summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_incomingrequests.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-03-13 02:16:21 +0000
committerJeremy Allison <jra@samba.org>2004-03-13 02:16:21 +0000
commit6b9dbbcd249360fb9acd61d6900baccf621c9cce (patch)
tree612e870056d4060da62d02ed05f38f1d99cd620d /source3/nmbd/nmbd_incomingrequests.c
parentfd2d4f87d440f24df0adc4cc29f22051536b0dee (diff)
downloadsamba-6b9dbbcd249360fb9acd61d6900baccf621c9cce.tar.gz
samba-6b9dbbcd249360fb9acd61d6900baccf621c9cce.tar.bz2
samba-6b9dbbcd249360fb9acd61d6900baccf621c9cce.zip
Modified fix for bugid #784. Based on a patch from moriyama@miraclelinux.com (MORIYAMA Masayuki).
Don't use nstrings to hold workgroup and netbios names. The problem with them is that MB netbios and workgroup names in unix charset (particularly utf8) may be up to 3x bigger than the name when represented in dos charset (ie. cp932). So go back to using fstrings for these but translate into nstrings (ie. 16 byte length values) for transport on the wire. Jeremy. (This used to be commit b4ea493599ab414f7828b83f40a5a8b43479ff64)
Diffstat (limited to 'source3/nmbd/nmbd_incomingrequests.c')
-rw-r--r--source3/nmbd/nmbd_incomingrequests.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c
index dd999fbdf7..d43cefc0df 100644
--- a/source3/nmbd/nmbd_incomingrequests.c
+++ b/source3/nmbd/nmbd_incomingrequests.c
@@ -58,7 +58,7 @@ void process_name_release_request(struct subnet_record *subrec,
struct nmb_packet *nmb = &p->packet.nmb;
struct in_addr owner_ip;
struct nmb_name *question = &nmb->question.question_name;
- nstring qname;
+ fstring qname;
BOOL bcast = nmb->header.nm_flags.bcast;
uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
BOOL group = (nb_flags & NB_GROUP) ? True : False;
@@ -98,7 +98,7 @@ subnet %s from owner IP %s\n",
* names and *don't set the group bit* !!!!!
*/
- pull_ascii_nstring(qname, question->name);
+ pull_ascii_nstring(qname, sizeof(qname), question->name);
if( !group && !ismyip(owner_ip) && strequal(qname, lp_workgroup()) &&
((question->name_type == 0x0) || (question->name_type == 0x1e))) {
DEBUG(6,("process_name_release_request: FTP OnNet bug workaround. Ignoring \
@@ -275,11 +275,13 @@ We put our own names first, then in alphabetical order.
static int status_compare(char *n1,char *n2)
{
- nstring name1, name2;
+ fstring name1, name2;
int l1,l2,l3;
- pull_ascii_nstring(name1, n1);
- pull_ascii_nstring(name2, n2);
+ memset(name1, '\0', sizeof(name1));
+ memset(name2, '\0', sizeof(name2));
+ pull_ascii_nstring(name1, sizeof(name1), n1);
+ pull_ascii_nstring(name2, sizeof(name2), n2);
n1 = name1;
n2 = name2;
@@ -298,7 +300,7 @@ static int status_compare(char *n1,char *n2)
(l1!=l3 || strncmp(n1,global_myname(),l3) != 0))
return 1;
- return memcmp(n1,n2,sizeof(nstring));
+ return memcmp(n1,n2,sizeof(fstring));
}
/****************************************************************************
@@ -308,14 +310,14 @@ static int status_compare(char *n1,char *n2)
void process_node_status_request(struct subnet_record *subrec, struct packet_struct *p)
{
struct nmb_packet *nmb = &p->packet.nmb;
- nstring qname;
+ fstring qname;
int ques_type = nmb->question.question_name.name_type;
char rdata[MAX_DGRAM_SIZE];
char *countptr, *buf, *bufend, *buf0;
int names_added,i;
struct name_record *namerec;
- pull_ascii_nstring(qname, nmb->question.question_name.name);
+ pull_ascii_nstring(qname, sizeof(qname), nmb->question.question_name.name);
DEBUG(3,("process_node_status_request: status request for name %s from IP %s on \
subnet %s.\n", nmb_namestr(&nmb->question.question_name), inet_ntoa(p->ip), subrec->subnet_name));
@@ -342,9 +344,9 @@ subnet %s - name not found.\n", nmb_namestr(&nmb->question.question_name),
while (buf < bufend) {
if( (namerec->data.source == SELF_NAME) || (namerec->data.source == PERMANENT_NAME) ) {
int name_type = namerec->name.name_type;
- nstring name;
+ fstring name;
- pull_ascii_nstring(name, namerec->name.name);
+ pull_ascii_nstring(name, sizeof(name), namerec->name.name);
strupper_m(name);
if (!strequal(name,"*") &&
!strequal(name,"__SAMBA__") &&
@@ -352,10 +354,11 @@ subnet %s - name not found.\n", nmb_namestr(&nmb->question.question_name),
ques_type < 0x1b || ques_type >= 0x20 ||
strequal(qname, name))) {
/* Start with the name. */
- nstring tmp_name;
- memset(tmp_name,'\0',sizeof(tmp_name));
- snprintf(tmp_name, sizeof(tmp_name), "%-15.15s",name);
- push_ascii_nstring(buf, tmp_name);
+ size_t len;
+ push_ascii_nstring(buf, name);
+ len = strlen(buf);
+ memset(buf + len, ' ', MAX_NETBIOSNAME_LEN - len - 1);
+ buf[MAX_NETBIOSNAME_LEN - 1] = '\0';
/* Put the name type and netbios flags in the buffer. */