Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickid2018 committed Sep 24, 2024
1 parent aa9fffa commit 76338cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mc_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int proto_mcbe = -1;
module_t *pref_mc = NULL;
gchar *pref_protocol_data_dir;
module_t *pref_mcje = NULL;
gchar *pref_ignore_packets_je = "c:map_chunk";
gchar *pref_ignore_packets_je = "";
gchar *pref_secret_key = "";
bool pref_do_nbt_decode = false;

Expand Down
18 changes: 15 additions & 3 deletions protocol/schema/schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,15 @@ DISSECT_PROTOCOL(codec) {
gchar *key = wmem_map_lookup(packet_saves, search_key);
if (key == NULL) return add_invalid_data(tree, tvb, offset, name, "No value found, protocol has error?");
protocol_dissector *sub = wmem_map_lookup(map, key);
if (sub == NULL) {
int64_t length = g_utf8_strlen(key, 400);
int64_t split_pos = length - 1;
for (; split_pos >= 0; split_pos--)
if (key[split_pos] == '/' || key[split_pos] == ':')
break;
key = g_utf8_substring(key, split_pos + 1, length);
sub = wmem_map_lookup(map, key);
}
if (sub == NULL) return add_invalid_data(tree, tvb, offset, name, "No codec found");
return sub->dissect_protocol(tree, pinfo, tvb, offset, sub, name, packet_saves, value);
}
Expand All @@ -634,16 +643,19 @@ DISSECT_PROTOCOL(top_bit_set_terminated_array) {
int32_t len = 0;
protocol_dissector *sub_dissector = wmem_map_lookup(dissector->dissect_arguments, "d");
if (tree) tree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_mc, NULL, name);
while (((now = tvb_get_uint8(tvb, offset + len)) & 0x80) != 0) {
bool do_loop = true;
while (do_loop) {
now = tvb_get_uint8(tvb, offset + len);
do_loop = (now & 0x80) != 0;
uint32_t ord = now & 0x7F;
int32_t sub_len = sub_dissector->dissect_protocol(
tree, pinfo, tvb, offset + len, sub_dissector, g_strdup_printf("%s[%d]", name, ord), packet_saves, NULL
);
if (sub_len == DISSECT_ERROR) return DISSECT_ERROR;
len += sub_len;
}
if (tree) proto_item_set_len(tree, len + 1);
return len + 1;
if (tree) proto_item_set_len(tree, len);
return len;
}

DISSECT_PROTOCOL(entity_metadata_loop) {
Expand Down
2 changes: 1 addition & 1 deletion utils/nbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void parse_to_string(tvbuff_t *tvb, packet_info *pinfo, int offset_global, guint
break;
default:
*length = 0;
*text = g_strdup_printf("Unknown type '%x'", type);
*text = g_strdup_printf("<NBT Error> Unknown type '%x'", type);
break;
}
}
Expand Down

0 comments on commit 76338cc

Please sign in to comment.