Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F132396188
D4622.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D4622.diff
View Options
Index: head/contrib/smbfs/lib/smb/nb_name.c
===================================================================
--- head/contrib/smbfs/lib/smb/nb_name.c
+++ head/contrib/smbfs/lib/smb/nb_name.c
@@ -143,15 +143,13 @@
return len;
}
-#define NBENCODE(c) (htole16((u_short)(((u_char)(c) >> 4) | \
- (((u_char)(c) & 0xf) << 8)) + 0x4141))
-
-static void
-memsetw(char *dst, int n, u_short word)
+static inline void
+nb_char_encode(u_char **ptr, u_char c, int n)
{
+
while (n--) {
- *(u_short*)dst = word;
- dst += 2;
+ *(*ptr)++ = 0x41 + (c >> 4);
+ *(*ptr)++ = 0x41 + (c & 0x0f);
}
}
@@ -165,19 +163,15 @@
*cp++ = NB_ENCNAMELEN;
name = np->nn_name;
if (name[0] == '*' && name[1] == 0) {
- *(u_short*)cp = NBENCODE('*');
- memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' '));
- cp += NB_ENCNAMELEN;
+ nb_char_encode(&cp, '*', 1);
+ nb_char_encode(&cp, ' ', NB_NAMELEN - 1);
} else {
- for (i = 0; *name && i < NB_NAMELEN - 1; i++, cp += 2, name++)
- *(u_short*)cp = NBENCODE(toupper(*name));
- i = NB_NAMELEN - i - 1;
- if (i > 0) {
- memsetw(cp, i, NBENCODE(' '));
- cp += i * 2;
- }
- *(u_short*)cp = NBENCODE(np->nn_type);
- cp += 2;
+ for (i = 0; i < NB_NAMELEN - 1; i++)
+ if (*name != 0)
+ nb_char_encode(&cp, toupper(*name++), 1);
+ else
+ nb_char_encode(&cp, ' ', 1);
+ nb_char_encode(&cp, np->nn_type, 1);
}
*cp = 0;
if (np->nn_scope == NULL)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 17, 1:49 PM (16 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23833739
Default Alt Text
D4622.diff (1 KB)
Attached To
Mode
D4622: Avoid unaligned memory accesses when encoding netbios names in mount_smbfs
Attached
Detach File
Event Timeline
Log In to Comment