HSP+HFP: Fix invalid UTF-8 string truncation

Fixes #18656.
This commit is contained in:
João Valverde 2022-11-25 19:31:34 +00:00
parent 27ea011dd3
commit d42ff693d9
2 changed files with 4 additions and 6 deletions

View File

@ -20,6 +20,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/strutil.h>
#include "packet-btrfcomm.h"
#include "packet-btsdp.h"
@ -1919,9 +1920,7 @@ dissect_at_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (i_at_cmd && i_at_cmd->name == NULL) {
char *name;
name = (char *) wmem_alloc(wmem_packet_scope(), i_char + 2);
(void) g_strlcpy(name, at_command, i_char + 1);
name[i_char + 1] = '\0';
name = format_text(wmem_packet_scope(), at_command, i_char + 1);
proto_item_append_text(command_item, ": %s (Unknown)", name);
proto_item_append_text(pitem, " (Unknown - Non-Standard HFP Command)");
expert_add_info(pinfo, pitem, &ei_non_mandatory_command);

View File

@ -15,6 +15,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/strutil.h>
#include "packet-btrfcomm.h"
#include "packet-btsdp.h"
@ -394,9 +395,7 @@ dissect_at_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (i_at_cmd && i_at_cmd->name == NULL) {
char *name;
name = (char *) wmem_alloc(wmem_packet_scope(), i_char + 2);
(void) g_strlcpy(name, at_command, i_char + 1);
name[i_char + 1] = '\0';
name = format_text(wmem_packet_scope(), at_command, i_char + 1);
proto_item_append_text(command_item, ": %s (Unknown)", name);
proto_item_append_text(pitem, " (Unknown - Non-Standard HSP Command)");
expert_add_info(pinfo, pitem, &ei_non_mandatory_command);