Avoid lots of stupid alignement problems.
You can now actually use this on sparc64 systems. Unfortunately the kernel part contains lots more of this ****** code.
This commit is contained in:
parent
5463479362
commit
58a4ff2fef
19
dist/smbfs/lib/smb/nb_name.c
vendored
19
dist/smbfs/lib/smb/nb_name.c
vendored
@ -145,9 +145,11 @@ nb_encname_len(const char *str)
|
|||||||
static void
|
static void
|
||||||
memsetw(char *dst, int n, u_short word)
|
memsetw(char *dst, int n, u_short word)
|
||||||
{
|
{
|
||||||
|
unsigned char c2 = word & 0x00ff;
|
||||||
|
unsigned char c1 = (word>>8) & 0x00ff;
|
||||||
while (n--) {
|
while (n--) {
|
||||||
*(u_short*)dst = word;
|
*dst++ = c1;
|
||||||
dst += 2;
|
*dst++ = c2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,22 +159,27 @@ nb_name_encode(struct nb_name *np, u_char *dst)
|
|||||||
u_char *name, *plen;
|
u_char *name, *plen;
|
||||||
u_char *cp = dst;
|
u_char *cp = dst;
|
||||||
int i, lblen;
|
int i, lblen;
|
||||||
|
u_int16_t ch;
|
||||||
|
|
||||||
*cp++ = NB_ENCNAMELEN;
|
*cp++ = NB_ENCNAMELEN;
|
||||||
name = np->nn_name;
|
name = np->nn_name;
|
||||||
if (name[0] == '*' && name[1] == 0) {
|
if (name[0] == '*' && name[1] == 0) {
|
||||||
*(u_short*)cp = NBENCODE('*');
|
ch = NBENCODE('*');
|
||||||
|
memcpy(cp, &ch, 2);
|
||||||
memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' '));
|
memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' '));
|
||||||
cp += NB_ENCNAMELEN;
|
cp += NB_ENCNAMELEN;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; *name && i < NB_NAMELEN; i++, cp += 2, name++)
|
for (i = 0; *name && i < NB_NAMELEN; i++, cp += 2, name++) {
|
||||||
*(u_short*)cp = NBENCODE(toupper(*name));
|
ch = NBENCODE(toupper(*name));
|
||||||
|
memcpy(cp, &ch, 2);
|
||||||
|
}
|
||||||
i = NB_NAMELEN - i - 1;
|
i = NB_NAMELEN - i - 1;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
memsetw(cp, i, NBENCODE(' '));
|
memsetw(cp, i, NBENCODE(' '));
|
||||||
cp += i * 2;
|
cp += i * 2;
|
||||||
}
|
}
|
||||||
*(u_short*)cp = NBENCODE(np->nn_type);
|
ch = NBENCODE(np->nn_type);
|
||||||
|
memcpy(cp, &ch, 2);
|
||||||
cp += 2;
|
cp += 2;
|
||||||
}
|
}
|
||||||
*cp = 0;
|
*cp = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user