NetBIOS: Don't write past the beginning of a buffer.

Make sure process_netbios_name doesn't write past the beginning of its
buffer.

Bug: 14249
Change-Id: Idb294ba2362e48b879bc4c0c0ddaf64fcf1b5d72
Reviewed-on: https://code.wireshark.org/review/24651
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Gerald Combs 2017-11-29 14:46:10 -08:00 committed by Michael Mann
parent 52365a55e4
commit b59dc97dfe
1 changed files with 2 additions and 1 deletions

View File

@ -298,6 +298,7 @@ process_netbios_name(const guchar *name_ptr, char *name_ret, int name_ret_len)
int i;
int name_type = *(name_ptr + NETBIOS_NAME_LEN - 1);
guchar name_char;
char *name_ret_orig = name_ret;
static const char hex_digits[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
for (i = 0; i < NETBIOS_NAME_LEN - 1; i++) {
@ -324,7 +325,7 @@ process_netbios_name(const guchar *name_ptr, char *name_ret, int name_ret_len)
name_ret--;
for (i = 0; i < NETBIOS_NAME_LEN - 1; i++) {
while (name_ret >= name_ret_orig) {
if (*name_ret != ' ') {
*(name_ret + 1) = 0;
break;