Commit 85e7dc6b authored by Michael Meeks's avatar Michael Meeks

Fatal font bug fix

parent 591cc547
1998-11-14 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excel_set_cell_font): Fixed buffer
overflow bug, and secured sprintf.
1998-11-12 Bruno Unna <bruno@iac.com.mx> 1998-11-12 Bruno Unna <bruno@iac.com.mx>
* plugins/excel/ms-excel.c: added support for fount size. * plugins/excel/ms-excel.c: added support for fount size.
......
1998-11-14 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excel_set_cell_font): Fixed buffer
overflow bug, and secured sprintf.
1998-11-12 Bruno Unna <bruno@iac.com.mx> 1998-11-12 Bruno Unna <bruno@iac.com.mx>
* plugins/excel/ms-excel.c: added support for fount size. * plugins/excel/ms-excel.c: added support for fount size.
......
1998-11-14 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excel_set_cell_font): Fixed buffer
overflow bug, and secured sprintf.
1998-11-12 Bruno Unna <bruno@iac.com.mx> 1998-11-12 Bruno Unna <bruno@iac.com.mx>
* plugins/excel/ms-excel.c: added support for fount size. * plugins/excel/ms-excel.c: added support for fount size.
......
1998-11-14 Michael Meeks <michael@imaginator.com>
* plugins/excel/ms-excel.c(ms_excel_set_cell_font): Fixed buffer
overflow bug, and secured sprintf.
1998-11-12 Bruno Unna <bruno@iac.com.mx> 1998-11-12 Bruno Unna <bruno@iac.com.mx>
* plugins/excel/ms-excel.c: added support for fount size. * plugins/excel/ms-excel.c: added support for fount size.
......
...@@ -358,11 +358,11 @@ ms_excel_set_cell_colors (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ...@@ -358,11 +358,11 @@ ms_excel_set_cell_colors (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
static void static void
ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
{ {
char font_size[10]; /* I know it may seem excessive. Time will say. */ char font_size[16]; /* I know it may seem excessive. Time will say. */
int i; int i;
GList *ptr = g_list_first (sheet->wb->font_data) ; GList *ptr = g_list_first (sheet->wb->font_data) ;
int idx = 0 ; int idx = 0 ;
g_assert (idx!=4) ; g_assert (idx!=4) ;
while (ptr) while (ptr)
{ {
...@@ -377,7 +377,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ...@@ -377,7 +377,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
* In our first attempt to make it work, let's try to guess the * In our first attempt to make it work, let's try to guess the
* X font name from the windows name, by letting the first word * X font name from the windows name, by letting the first word
* of the name be inserted in 0'th position of the X font name. */ * of the name be inserted in 0'th position of the X font name. */
for (i=0; fd->fontname[i] != ' '; ++i) for (i=0; fd->fontname[i] != '\0' && fd->fontname[i] != ' '; ++i)
fd->fontname[i] = tolower (fd->fontname[i]); fd->fontname[i] = tolower (fd->fontname[i]);
fd->fontname[i] = '\x0'; fd->fontname[i] = '\x0';
cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname)); cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname));
...@@ -392,7 +392,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ...@@ -392,7 +392,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
cell->style->font->hint_is_bold = 1; cell->style->font->hint_is_bold = 1;
} }
/* What about underlining? */ /* What about underlining? */
sprintf (font_size, "%d", fd->height/2); g_assert (snprintf (font_size, 16, "%d", fd->height/2)!=-1) ;
cell_set_font (cell, font_change_component (cell->style->font->font_name, 7, font_size)); cell_set_font (cell, font_change_component (cell->style->font->font_name, 7, font_size));
/* delete me: */ /* delete me: */
printf ("The new font name is: %s\n", cell->style->font->font_name); printf ("The new font name is: %s\n", cell->style->font->font_name);
...@@ -409,7 +409,7 @@ ms_excel_set_cell_xf(MS_EXCEL_SHEET *sheet, Cell *cell, int xfidx) ...@@ -409,7 +409,7 @@ ms_excel_set_cell_xf(MS_EXCEL_SHEET *sheet, Cell *cell, int xfidx)
{ {
GList *ptr ; GList *ptr ;
int cnt ; int cnt ;
if (xfidx == 0) if (xfidx == 0)
{ {
printf ("Normal cell formatting\n") ; printf ("Normal cell formatting\n") ;
......
...@@ -358,11 +358,11 @@ ms_excel_set_cell_colors (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ...@@ -358,11 +358,11 @@ ms_excel_set_cell_colors (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
static void static void
ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
{ {
char font_size[10]; /* I know it may seem excessive. Time will say. */ char font_size[16]; /* I know it may seem excessive. Time will say. */
int i; int i;
GList *ptr = g_list_first (sheet->wb->font_data) ; GList *ptr = g_list_first (sheet->wb->font_data) ;
int idx = 0 ; int idx = 0 ;
g_assert (idx!=4) ; g_assert (idx!=4) ;
while (ptr) while (ptr)
{ {
...@@ -377,7 +377,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ...@@ -377,7 +377,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
* In our first attempt to make it work, let's try to guess the * In our first attempt to make it work, let's try to guess the
* X font name from the windows name, by letting the first word * X font name from the windows name, by letting the first word
* of the name be inserted in 0'th position of the X font name. */ * of the name be inserted in 0'th position of the X font name. */
for (i=0; fd->fontname[i] != ' '; ++i) for (i=0; fd->fontname[i] != '\0' && fd->fontname[i] != ' '; ++i)
fd->fontname[i] = tolower (fd->fontname[i]); fd->fontname[i] = tolower (fd->fontname[i]);
fd->fontname[i] = '\x0'; fd->fontname[i] = '\x0';
cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname)); cell_set_font (cell, font_change_component (cell->style->font->font_name, 1, fd->fontname));
...@@ -392,7 +392,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf) ...@@ -392,7 +392,7 @@ ms_excel_set_cell_font (MS_EXCEL_SHEET *sheet, Cell *cell, BIFF_XF_DATA *xf)
cell->style->font->hint_is_bold = 1; cell->style->font->hint_is_bold = 1;
} }
/* What about underlining? */ /* What about underlining? */
sprintf (font_size, "%d", fd->height/2); g_assert (snprintf (font_size, 16, "%d", fd->height/2)!=-1) ;
cell_set_font (cell, font_change_component (cell->style->font->font_name, 7, font_size)); cell_set_font (cell, font_change_component (cell->style->font->font_name, 7, font_size));
/* delete me: */ /* delete me: */
printf ("The new font name is: %s\n", cell->style->font->font_name); printf ("The new font name is: %s\n", cell->style->font->font_name);
...@@ -409,7 +409,7 @@ ms_excel_set_cell_xf(MS_EXCEL_SHEET *sheet, Cell *cell, int xfidx) ...@@ -409,7 +409,7 @@ ms_excel_set_cell_xf(MS_EXCEL_SHEET *sheet, Cell *cell, int xfidx)
{ {
GList *ptr ; GList *ptr ;
int cnt ; int cnt ;
if (xfidx == 0) if (xfidx == 0)
{ {
printf ("Normal cell formatting\n") ; printf ("Normal cell formatting\n") ;
......
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