summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tftp.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 17:44:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 17:44:17 +0000
commit2d78050fd56b8188aa5a65ad2667e301b60eea45 (patch)
treeb54d4adac6de0a196b8bb8a67b34fe186c21378f /epan/dissectors/packet-tftp.c
parentAdding upstream version 4.2.2. (diff)
downloadwireshark-2d78050fd56b8188aa5a65ad2667e301b60eea45.tar.xz
wireshark-2d78050fd56b8188aa5a65ad2667e301b60eea45.zip
Adding upstream version 4.2.4.upstream/4.2.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-tftp.c')
-rw-r--r--epan/dissectors/packet-tftp.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c
index e543ea8..075e754 100644
--- a/epan/dissectors/packet-tftp.c
+++ b/epan/dissectors/packet-tftp.c
@@ -588,11 +588,22 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info,
tftp_info->is_simple_file /* This is a simple file */
&& filename != NULL /* There is a file name */
&& !tftp_info->blocks_missing /* No missing blocks */
- && tftp_info->last_package_available /* Last package known */
+ && (tftp_info->last_package_available || !PINFO_FD_VISITED(pinfo))
+ /* If this is the first pass (i.e., this is tshark one-pass
+ * mode and we're tapping), then we can't know if the last
+ * block is present in the file yet. */
) {
- if (blocknum == 1 && !tftp_info->payload_data) {
+ if (PINFO_FD_VISITED(pinfo)) {
+ if (blocknum == 1 && !tftp_info->payload_data) {
tftp_info->payload_data = (guint8 *)g_try_malloc((gsize)tftp_info->file_length);
+ }
+ } else {
+ /* We allocate this in file scope so that it doesn't leak if it
+ * turns out we don't have all the blocks so we never send this
+ * to the tap.
+ */
+ tftp_info->payload_data = (guint8 *)wmem_realloc(wmem_file_scope(), tftp_info->payload_data, (gsize)tftp_info->file_length);
}
if (tftp_info->payload_data == NULL ||
@@ -779,7 +790,7 @@ is_valid_request_body(tvbuff_t *tvb)
guint len = tvb_strsize(tvb, offset);
const gchar* mode = tvb_format_stringzpad(wmem_packet_scope(), tvb, offset, len);
- const gchar* modes[] = {"netscii", "octet", "mail"};
+ const gchar* modes[] = {"netascii", "octet", "mail"};
for(guint i = 0; i < array_length(modes); ++i) {
if (g_ascii_strcasecmp(mode, modes[i]) == 0) return TRUE;
}