diff options
author | Jeremy Allison <jra@samba.org> | 2004-03-13 02:16:21 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-03-13 02:16:21 +0000 |
commit | b4ea493599ab414f7828b83f40a5a8b43479ff64 (patch) | |
tree | 22c0a11234617145009a9c2f26038914c5f7cb0e /source/nmbd/nmbd_workgroupdb.c | |
parent | 966e49a48c352563cdd7f75fe2768f2d6612ec7e (diff) | |
download | samba-b4ea493599ab414f7828b83f40a5a8b43479ff64.tar.gz samba-b4ea493599ab414f7828b83f40a5a8b43479ff64.tar.xz samba-b4ea493599ab414f7828b83f40a5a8b43479ff64.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.
Diffstat (limited to 'source/nmbd/nmbd_workgroupdb.c')
-rw-r--r-- | source/nmbd/nmbd_workgroupdb.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/source/nmbd/nmbd_workgroupdb.c b/source/nmbd/nmbd_workgroupdb.c index b9fab4b278c..bd2737ef972 100644 --- a/source/nmbd/nmbd_workgroupdb.c +++ b/source/nmbd/nmbd_workgroupdb.c @@ -48,6 +48,8 @@ static struct work_record *create_workgroup(const char *name, int ttl) { struct work_record *work; struct subnet_record *subrec; + nstring nname; + int t = -1; if((work = (struct work_record *)malloc(sizeof(*work))) == NULL) { @@ -55,15 +57,18 @@ static struct work_record *create_workgroup(const char *name, int ttl) return NULL; } memset((char *)work, '\0', sizeof(*work)); - - if (strlen(name)+1 > sizeof(nstring)) { - memcpy(work->work_group,name,sizeof(nstring)-1); - work->work_group[sizeof(nstring)-1] = '\0'; - DEBUG(0,("create_workgroup: workgroup name %s is too long. Truncating to %s\n", - name, work->work_group )); - } else { - nstrcpy(work->work_group,name); - } + + errno = 0; + push_ascii_nstring(nname, name); + if (errno == E2BIG) { + fstring tname; + pull_ascii_nstring(tname, sizeof(tname), nname); + fstrcpy(work->work_group,tname); + DEBUG(0,("create_workgroup: workgroup name %s is too long. Truncating to %s\n", + name, tname)); + } else { + fstrcpy(work->work_group,name); + } work->serverlist = NULL; work->RunningElection = False; |