aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/utils/field_information.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/utils/field_information.cpp')
-rw-r--r--ui/qt/utils/field_information.cpp51
1 files changed, 8 insertions, 43 deletions
diff --git a/ui/qt/utils/field_information.cpp b/ui/qt/utils/field_information.cpp
index fc58222101..aac03277c5 100644
--- a/ui/qt/utils/field_information.cpp
+++ b/ui/qt/utils/field_information.cpp
@@ -4,19 +4,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <stdint.h>
@@ -87,29 +75,22 @@ bool FieldInformation::tvbContains(FieldInformation *child)
FieldInformation::Position FieldInformation::position() const
{
- Position pos = {-1, -1, -1};
+ Position pos = {-1, -1};
if ( fi_ && fi_->ds_tvb )
{
- guint len = tvb_captured_length(fi_->ds_tvb);
+ int len = (int) tvb_captured_length(fi_->ds_tvb);
pos.start = fi_->start;
pos.length = fi_->length;
- if (pos.start >= 0 && pos.length > 0 && (guint)pos.start < len)
- {
- pos.end = pos.start + pos.length;
- }
- else
+ if (pos.start < 0 || pos.length < 0 || pos.start >= len)
{
- if ( fi_->appendix_start >= 0 && fi_->appendix_length > 0 && (guint)fi_->appendix_start < len )
+ if ( fi_->appendix_start >= 0 && fi_->appendix_length > 0 && fi_->appendix_start < len )
{
pos.start = fi_->appendix_start;
- pos.end = fi_->appendix_start + fi_->appendix_length;
+ pos.length = fi_->appendix_length;
}
}
-
- if (pos.end != -1 && (guint)pos.end > len)
- pos.end = len;
}
return pos;
@@ -117,31 +98,16 @@ FieldInformation::Position FieldInformation::position() const
FieldInformation::Position FieldInformation::appendix() const
{
- Position pos = {-1, -1, -1};
+ Position pos = {-1, -1};
if ( fi_ && fi_->ds_tvb )
{
- guint len = tvb_captured_length(fi_->ds_tvb);
-
pos.start = fi_->appendix_start;
pos.length = fi_->appendix_length;
-
- if (pos.start >= 0 && pos.length > 0 && (guint)pos.start < len)
- pos.end = pos.start + pos.length;
-
- /* sanity check with total field length */
- if ( position().end == -1 )
- {
- pos.start = -1;
- pos.end = -1;
- }
-
- if (pos.end != -1 && (guint)pos.end > len)
- pos.end = len;
}
return pos;
}
-#include <QDebug>
+
QByteArray FieldInformation::printableData()
{
QByteArray data;
@@ -154,7 +120,6 @@ QByteArray FieldInformation::printableData()
int length = pos.length;
if ( length > rem_length )
length = rem_length;
-qDebug() << "Bin hier";
uint8_t * dataSet = (uint8_t *)tvb_memdup(wmem_file_scope(), fi_->ds_tvb, pos.start, length );
data = QByteArray::fromRawData((char *)dataSet, length);
}