mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +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
0375dace24
commit
966e49a48c
@ -1504,7 +1504,8 @@ struct cnotify_fns {
|
||||
|
||||
#include "smb_macros.h"
|
||||
|
||||
typedef char nstring[16];
|
||||
#define MAX_NETBIOSNAME_LEN 16
|
||||
typedef char nstring[MAX_NETBIOSNAME_LEN];
|
||||
|
||||
/* A netbios name structure. */
|
||||
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);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Push an nstring - ensure null terminated. Written by
|
||||
moriyama@miraclelinux.com (MORIYAMA Masayuki).
|
||||
********************************************************************/
|
||||
|
||||
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)
|
||||
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
|
||||
|
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 msg_type = CVAL(inbuf,0);
|
||||
int msg_flags = CVAL(inbuf,1);
|
||||
pstring name1,name2;
|
||||
fstring name1,name2;
|
||||
char name_type = 0;
|
||||
|
||||
static BOOL already_got_session = False;
|
||||
|
Loading…
Reference in New Issue
Block a user