Commit bf4852dc authored by Almer S. Tigelaar's avatar Almer S. Tigelaar Committed by Almer S. Tigelaar

Fix.

2001-06-03  Almer S. Tigelaar  <almer@gnome.org>

	* src/stf-parse.c (stf_parse_get_longest_row_width): Fix.

2001-06-03  Almer S. Tigelaar  <almer@gnome.org>

	* dialog-stf.h: Define X overflow limit.

	* dialog-stf-preview.c (stf_preview_render_row): Really
	truncate strings if they are too long.

	* dialog-stf-main-page.c (stf_dialog_main_page_init): Protect
	against overly large text.
parent 77cadcab
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.c (stf_parse_get_longest_row_width): Fix.
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/parse-util.[ch] (row_name): New, converts
a row number to a string.
(rows_name): Idem, but for a start/end range.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.c (stf_parse_get_longest_row_width): Fix.
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/parse-util.[ch] (row_name): New, converts
a row number to a string.
(rows_name): Idem, but for a start/end range.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.c (stf_parse_get_longest_row_width): Fix.
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/parse-util.[ch] (row_name): New, converts
a row number to a string.
(rows_name): Idem, but for a start/end range.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.c (stf_parse_get_longest_row_width): Fix.
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/parse-util.[ch] (row_name): New, converts
a row number to a string.
(rows_name): Idem, but for a start/end range.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/stf-parse.c (stf_parse_get_longest_row_width): Fix.
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* src/parse-util.[ch] (row_name): New, converts
a row number to a string.
(rows_name): Idem, but for a start/end range.
......
2001-06-03 Almer S. Tigelaar <almer@gnome.org>
* dialog-stf.h: Define X overflow limit.
* dialog-stf-preview.c (stf_preview_render_row): Really
truncate strings if they are too long.
* dialog-stf-main-page.c (stf_dialog_main_page_init): Protect
against overly large text.
* dialog-cell-sort.c (col_row_name):
Use row_name.
......
......@@ -175,7 +175,9 @@ stf_dialog_main_page_init (GladeXML *gui, DruidPageData_t *pagedata)
{
MainInfo_t *info = pagedata->main_info;
char *label;
const char *s;
GtkMenu *menu;
int l, lg;
/* Create/get object and fill information struct */
......@@ -188,16 +190,31 @@ stf_dialog_main_page_init (GladeXML *gui, DruidPageData_t *pagedata)
info->main_frame = GTK_FRAME (glade_xml_get_widget (gui, "main_frame"));
info->main_canvas = GNOME_CANVAS (glade_xml_get_widget (gui, "main_canvas"));
/*
* XFREE86 Overflow protection
*
* There is a bug in XFree86 (at least up until 4.0.3)
* which takes down the whole server if very large strings
* are drawn on a local display. We therefore simply _not_ display
* anything if the string is too large.
*/
for (lg = 0, l = 1, s = pagedata->data; s && *s != '\0'; s++, l++) {
if (*s == '\n' || *s == '\r' || s[1] == '\0') {
if (l > lg)
lg = l;
l = 0;
}
}
info->main_run_text = GNOME_CANVAS_TEXT (gnome_canvas_item_new (gnome_canvas_root (info->main_canvas),
GNOME_TYPE_CANVAS_TEXT,
"text", pagedata->data,
"text", lg < X_OVERFLOW_PROTECT ? pagedata->data : _("LINES TO LONG!"),
"font", "fixed",
"x", 0.0,
"y", 0.0,
"x_offset", TEXT_OFFSET,
"anchor", GTK_ANCHOR_NW,
NULL));
/* Warning : The rectangle is vital to prevent auto-centering, DON'T REMOVE IT! */
info->main_run_rect = GNOME_CANVAS_RECT (gnome_canvas_item_new (gnome_canvas_root (info->main_canvas),
gnome_canvas_rect_get_type (),
......@@ -208,7 +225,6 @@ stf_dialog_main_page_init (GladeXML *gui, DruidPageData_t *pagedata)
NULL));
/* Set properties */
main_page_set_spin_button_adjustment (info->main_startrow, 1, pagedata->lines);
main_page_set_spin_button_adjustment (info->main_stoprow, 1, pagedata->lines);
gtk_spin_button_set_value (info->main_stoprow, (float) pagedata->lines);
......
......@@ -300,10 +300,15 @@ stf_preview_render_row (RenderData_t *renderdata, double rowy, GSList *row, int
char *text = NULL;
/*
* We need an upper limit or else we'll crash X
* XFREE86 Overflow protection
*
* There is a bug in XFree86 (at least up until 4.0.3)
* which takes down the whole server if very large strings
* are drawn on a local display. We therefore simply truncate
* the string if it is 'too large' to display.
*/
if (strlen (iterator->data) > INT_MAX)
text = g_strndup (iterator->data, INT_MAX);
if (strlen (iterator->data) > X_OVERFLOW_PROTECT - 1)
text = g_strndup (iterator->data, X_OVERFLOW_PROTECT - 1);
/* In case the active color differs from the inactive color
* this code can be activated
......@@ -315,7 +320,7 @@ stf_preview_render_row (RenderData_t *renderdata, double rowy, GSList *row, int
*/
textwidth = stf_preview_draw_text (renderdata->group,
iterator->data,
text ? text : iterator->data,
renderdata->font,
TEXT_COLOR,
xpos + (CELL_HPAD / 2),
......
......@@ -18,6 +18,7 @@
#include "dialog-stf-preview.h"
#define LINE_DISPLAY_LIMIT 128
#define X_OVERFLOW_PROTECT 2048
/* Define for text offsets used on the main page of the druid */
#define TEXT_OFFSET 10.0
......
......@@ -864,7 +864,8 @@ stf_parse_get_longest_row_width (StfParseOptions_t *parseoptions, const char *da
iterator = data;
while (*iterator) {
if (*iterator == parseoptions->terminator) {
if (*iterator == parseoptions->terminator
|| iterator[1] == '\0') {
if (len > longest)
longest = len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment