The Samba-Bugzilla – Attachment 434 Details for
Bug 784
unix charset = UTF-8 Problem in a workgroup name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
A patch for extending NETBIOS name
samba-3.0.2a-netbios_i18n.patch (text/plain), 6.33 KB, created by
Shiro Yamada
on 2004-03-11 23:49:53 UTC
(
hide
)
Description:
A patch for extending NETBIOS name
Filename:
MIME Type:
Creator:
Shiro Yamada
Created:
2004-03-11 23:49:53 UTC
Size:
6.33 KB
patch
obsolete
>diff -uNr samba-3.0.2a.org/source/include/smb.h samba-3.0.2a/source/include/smb.h >--- samba-3.0.2a.org/source/include/smb.h 2004-01-17 02:47:52.000000000 +0900 >+++ samba-3.0.2a/source/include/smb.h 2004-03-02 16:12:36.000000000 +0900 >@@ -1487,7 +1487,10 @@ > > #include "smb_macros.h" > >-typedef char nstring[16]; >+#define MAX_NETBIOSNAME_LEN 16 >+ >+#define NSTRING_LEN 128 >+typedef char nstring[NSTRING_LEN]; > > /* A netbios name structure. */ > struct nmb_name { >diff -uNr samba-3.0.2a.org/source/lib/charcnv.c samba-3.0.2a/source/lib/charcnv.c >--- samba-3.0.2a.org/source/lib/charcnv.c 2004-03-02 15:55:51.000000000 +0900 >+++ samba-3.0.2a/source/lib/charcnv.c 2004-03-02 16:11:56.000000000 +0900 >@@ -813,7 +813,29 @@ > > size_t push_ascii_nstring(void *dest, const char *src) > { >- return push_ascii(dest, src, sizeof(nstring), STR_TERMINATE); >+ size_t i, buffer_len, dest_len; >+ smb_ucs2_t *buffer; >+ >+ buffer_len = push_ucs2_allocate(&buffer, src); >+ if (buffer_len == -1) { >+ smb_panic("failed to create UCS2 buffer"); >+ } >+ >+ dest_len = 0; >+ for (i = 0; i < buffer_len; i++) { >+ unsigned char mb[10]; >+ size_t mb_len = convert_string(CH_UCS2, CH_DOS, buffer+i, sizeof(smb_ucs2_t), mb, sizeof(mb)); >+ if (mb_len > 0 && dest_len + mb_len <= MAX_NETBIOSNAME_LEN - 1) { >+ memcpy((void *)((char *)dest + dest_len), (void *)mb, mb_len); >+ dest_len += mb_len; >+ } else { >+ break; >+ } >+ } >+ ((char *)dest)[dest_len] = '\0'; >+ >+ SAFE_FREE(buffer); >+ return dest_len; > } > > /** >diff -uNr samba-3.0.2a.org/source/libsmb/namequery.c samba-3.0.2a/source/libsmb/namequery.c >--- samba-3.0.2a.org/source/libsmb/namequery.c 2004-01-17 02:47:53.000000000 +0900 >+++ samba-3.0.2a/source/libsmb/namequery.c 2004-03-02 16:11:56.000000000 +0900 >@@ -202,7 +202,7 @@ > if (i == count) > goto done; > >- pull_ascii(name, status[i].name, 16, 15, STR_TERMINATE); >+ pull_ascii_nstring(name, status[i].name); > > /* Store the result in the cache. */ > /* but don't store an entry for 0x1c names here. Here we have >diff -uNr samba-3.0.2a.org/source/libsmb/nmblib.c samba-3.0.2a/source/libsmb/nmblib.c >--- samba-3.0.2a.org/source/libsmb/nmblib.c 2003-08-29 06:42:43.000000000 +0900 >+++ samba-3.0.2a/source/libsmb/nmblib.c 2004-03-02 16:11:56.000000000 +0900 >@@ -256,6 +256,19 @@ > return(ret); > } > >+/**************************************************************************** >+put a netbios name, padding(s) and a name type >+****************************************************************************/ >+static void put_name(char *dest, const char *name, int pad, unsigned int name_type) >+{ >+ size_t len = strlen(name); >+ >+ memcpy(dest, name, (len < MAX_NETBIOSNAME_LEN) ? len : MAX_NETBIOSNAME_LEN - 1); >+ if (len < MAX_NETBIOSNAME_LEN - 1) { >+ memset(dest + len, pad, MAX_NETBIOSNAME_LEN - 1 - len); >+ } >+ dest[MAX_NETBIOSNAME_LEN - 1] = name_type; >+} > > /******************************************************************* > put a compressed nmb name into a buffer. return the length of the >@@ -268,16 +281,14 @@ > static int put_nmb_name(char *buf,int offset,struct nmb_name *name) > { > int ret,m; >- fstring buf1; >+ nstring buf1; > char *p; > > if (strcmp(name->name,"*") == 0) { > /* special case for wildcard name */ >- memset(buf1,'\0',20); >- buf1[0] = '*'; >- buf1[15] = name->name_type; >+ put_name(buf1, "*", '\0', name->name_type); > } else { >- slprintf(buf1, sizeof(buf1) - 1,"%-15.15s%c",name->name,name->name_type); >+ put_name(buf1, name->name, ' ', name->name_type); > } > > buf[offset] = 0x20; >@@ -1182,17 +1193,21 @@ > int name_mangle( char *In, char *Out, char name_type ) > { > int i; >- int c; > int len; >- char buf[20]; >+ nstring buf; > char *p = Out; > > /* Safely copy the input string, In, into buf[]. */ >- (void)memset( buf, 0, 20 ); > if (strcmp(In,"*") == 0) >- buf[0] = '*'; >- else >- (void)slprintf( buf, sizeof(buf) - 1, "%-15.15s%c", In, name_type ); >+ put_name(buf, "*", '\0', 0x00); >+ else { >+ nstring buf_unix, buf_dos; >+ >+ pull_ascii_nstring(buf_unix, In); >+ strupper_m(buf_unix, sizeof(buf_unix)); >+ push_ascii_nstring(buf_dos, buf_unix); >+ put_name(buf, buf_dos, ' ', name_type); >+ } > > /* Place the length of the first field into the output buffer. */ > p[0] = 32; >@@ -1201,9 +1216,8 @@ > /* Now convert the name to the rfc1001/1002 format. */ > for( i = 0; i < 16; i++ ) > { >- c = toupper( buf[i] ); >- p[i*2] = ( (c >> 4) & 0x000F ) + 'A'; >- p[(i*2)+1] = (c & 0x000F) + 'A'; >+ p[i*2] = ( (buf[i] >> 4) & 0x000F ) + 'A'; >+ p[(i*2)+1] = (buf[i] & 0x000F) + 'A'; > } > p += 32; > p[0] = '\0'; >diff -uNr samba-3.0.2a.org/source/nmbd/nmbd_incomingrequests.c samba-3.0.2a/source/nmbd/nmbd_incomingrequests.c >--- samba-3.0.2a.org/source/nmbd/nmbd_incomingrequests.c 2004-03-02 15:55:51.000000000 +0900 >+++ samba-3.0.2a/source/nmbd/nmbd_incomingrequests.c 2004-03-02 16:11:56.000000000 +0900 >@@ -352,10 +352,11 @@ > 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); >+ int 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. */ > >diff -uNr samba-3.0.2a.org/source/smbd/negprot.c samba-3.0.2a/source/smbd/negprot.c >--- samba-3.0.2a.org/source/smbd/negprot.c 2004-03-02 15:55:51.000000000 +0900 >+++ samba-3.0.2a/source/smbd/negprot.c 2004-03-02 16:11:56.000000000 +0900 >@@ -170,6 +170,7 @@ > { > DATA_BLOB blob; > uint8 guid[17]; >+ nstring dos_name, unix_name; > const char *OIDs_krb5[] = {OID_KERBEROS5, > OID_KERBEROS5_OLD, > OID_NTLMSSP, >@@ -181,7 +182,10 @@ > global_spnego_negotiated = True; > > ZERO_STRUCT(guid); >- safe_strcpy((char *)guid, global_myname(), sizeof(guid)-1); >+ safe_strcpy(unix_name, global_myname(), sizeof(unix_name)-1); >+ strlower_m(unix_name, sizeof(nstring)); >+ push_ascii_nstring(dos_name, unix_name); >+ safe_strcpy((char *)guid, dos_name, sizeof(guid)-1); > > #ifdef DEVELOPER > /* valgrind fixer... */ >@@ -192,8 +196,6 @@ > } > #endif > >- strlower_m_fixlen((char *)guid); >- > #if 0 > /* strangely enough, NT does not sent the single OID NTLMSSP when > not a ADS member, it sends no OIDs at all
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 784
: 434