mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
First part of patch from moriyama@miraclelinux.com (MORIYAMA Masayuki) to
fix up netbios names with mb strings. Includes reformat of libsmb/nmblib.c so it's readable. Jeremy.
This commit is contained in:
parent
8e52439f4a
commit
beca3829d1
@ -1508,7 +1508,8 @@ struct cnotify_fns {
|
|||||||
|
|
||||||
#include "smb_macros.h"
|
#include "smb_macros.h"
|
||||||
|
|
||||||
typedef char nstring[16];
|
#define MAX_NETBIOSNAME_LEN 16
|
||||||
|
typedef char nstring[MAX_NETBIOSNAME_LEN];
|
||||||
|
|
||||||
/* A netbios name structure. */
|
/* A netbios name structure. */
|
||||||
struct nmb_name {
|
struct nmb_name {
|
||||||
|
@ -823,9 +823,37 @@ size_t push_ascii_pstring(void *dest, const char *src)
|
|||||||
return push_ascii(dest, src, sizeof(pstring), STR_TERMINATE);
|
return push_ascii(dest, src, sizeof(pstring), STR_TERMINATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
Push an nstring - ensure null terminated. Written by
|
||||||
|
moriyama@miraclelinux.com (MORIYAMA Masayuki).
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
size_t push_ascii_nstring(void *dest, const char *src)
|
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 == (size_t)-1) {
|
||||||
|
smb_panic("failed to create UCS2 buffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
dest_len = 0;
|
||||||
|
for (i = 0; i < buffer_len; i++) {
|
||||||
|
unsigned char mb[10];
|
||||||
|
/* Convert one smb_ucs2_t character at a time. */
|
||||||
|
size_t mb_len = convert_string(CH_UCS2, CH_DOS, buffer+i, sizeof(smb_ucs2_t), mb, sizeof(mb), False);
|
||||||
|
if ((mb_len != (size_t)-1) && (dest_len + mb_len <= MAX_NETBIOSNAME_LEN - 1)) {
|
||||||
|
memcpy((char *)dest + dest_len, mb, mb_len);
|
||||||
|
dest_len += mb_len;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
((char *)dest)[dest_len] = '\0';
|
||||||
|
|
||||||
|
SAFE_FREE(buffer);
|
||||||
|
return dest_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +202,7 @@ BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr t
|
|||||||
if (i == count)
|
if (i == count)
|
||||||
goto done;
|
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. */
|
/* Store the result in the cache. */
|
||||||
/* but don't store an entry for 0x1c names here. Here we have
|
/* but don't store an entry for 0x1c names here. Here we have
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -171,7 +171,7 @@ int reply_special(char *inbuf,char *outbuf)
|
|||||||
int outsize = 4;
|
int outsize = 4;
|
||||||
int msg_type = CVAL(inbuf,0);
|
int msg_type = CVAL(inbuf,0);
|
||||||
int msg_flags = CVAL(inbuf,1);
|
int msg_flags = CVAL(inbuf,1);
|
||||||
pstring name1,name2;
|
fstring name1,name2;
|
||||||
char name_type = 0;
|
char name_type = 0;
|
||||||
|
|
||||||
static BOOL already_got_session = False;
|
static BOOL already_got_session = False;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user