summaryrefslogtreecommitdiff
path: root/gtk/proto_draw.c
diff options
context:
space:
mode:
authorTomas Kukosa <tomas.kukosa@siemens.com>2007-11-21 13:11:13 +0000
committerTomas Kukosa <tomas.kukosa@siemens.com>2007-11-21 13:11:13 +0000
commitcfce233c75f8f5872facc6cb7bb3ba24094d774a (patch)
tree8b81d707e707f01f09461af8e64b4a67aa8d073c /gtk/proto_draw.c
parent7a4d6fbf3666e2137ef3584f82bc22b0fb69a035 (diff)
downloadwireshark-cfce233c75f8f5872facc6cb7bb3ba24094d774a.tar.gz
fix crash caused with memory overwrite (flush buffer into window when we do not have space for next line)
svn path=/trunk/; revision=23527
Diffstat (limited to 'gtk/proto_draw.c')
-rw-r--r--gtk/proto_draw.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index e24885f1b7..c2f61a42d8 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -324,11 +324,12 @@ toggle_tree(GtkCTree *ctree, GdkEventKey *event, gpointer user_data _U_)
3 characters per byte of hex dump,
2 blanks separating hex from ASCII,
1 character per byte of ASCII dump */
-#define MAX_LINES 100
-#define MAX_LINE_LEN (MAX_LINES *(MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN))
+#define MAX_LINE_LEN (MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN)
/* number of characters per line;
offset, 2 blanks separating offset
from data dump, data dump */
+#define MAX_LINES 100
+#define MAX_LINES_LEN (MAX_LINES*MAX_LINE_LEN)
/* Which byte the offset is referring to. Associates
* whitespace with the preceding digits. */
@@ -1157,7 +1158,7 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
int bend, int astart, int aend, int encoding)
{
int i = 0, j, k, cur;
- guchar line[MAX_LINE_LEN + 1];
+ guchar line[MAX_LINES_LEN + 1];
static guchar hexchars[16] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
@@ -1565,7 +1566,7 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart,
cur = 0;
}
line[cur++] = '\n';
- if (cur >= MAX_LINE_LEN) {
+ if (cur >= (MAX_LINES_LEN - MAX_LINE_LEN)) {
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, line, cur,
"plain", NULL);
cur = 0;