centos 6
integer weakness #25

2

Weakness Breakdown


Definition:

An integer overflow occurs when the answer to an arithmetic operation exceeds the maximum size of the integer type used to store it. The resulting value will appear to have wrapped around the maximum value and started again at the minimum value. This would look like a clock that represents 13:00 by pointing at 1:00. An attacker can use an integer overflow during a buffer length calculation, which results in the allocated buffer being too small to hold the data copied into it, thus causing a buffer overflow.

Warning code(s):

Unless checked, the resulting number can exceed the expected range.

File Name:

gtk+extra-2.1.1/gtkextra/gtkfontcombo.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 6 integer weakness.

   gint i;

  gtk_list_select_item(GTK_LIST(GTK_COMBO(combo->name_combo)->list), n);

  for(i = 0; i < NUM_SIZES; i++){
     if(atoi(default_sizes[i]) >= height) break;
  }

  if(i < NUM_SIZES)
    gtk_list_select_item(GTK_LIST(GTK_COMBO(combo->size_combo)->list), i);

  if(GTK_IS_TOGGLE_BUTTON(combo->bold_button))
    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(combo->bold_button), bold);
  if(GTK_IS_TOGGLE_BUTTON(combo->italic_button))
    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(combo->italic_button), italic);
}

gint 
gtk_font_combo_get_font_height (GtkFontCombo *combo)
{
  const gchar *size;

  size = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo->size_combo)->entry));

  return atoi(size);
}

GtkPSFont * 
gtk_font_combo_get_psfont (GtkFontCombo *combo)
{
  const gchar *text;
  gboolean italic = FALSE, bold = FALSE;

  text=gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo->name_combo)->entry));

  if(GTK_IS_TOGGLE_BUTTON(GTK_FONT_COMBO(combo)->italic_button))
    italic = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(GTK_FONT_COMBO(combo)->italic_button));
  if(GTK_IS_TOGGLE_BUTTON(GTK_FONT_COMBO(combo)->bold_button))
    bold = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(GTK_FONT_COMBO(combo)->bold_button));

  return (gtk_psfont_get_by_family(text, italic, bold));
}

PangoFontDescription * 
gtk_font_combo_get_font_description (GtkFontCombo *combo)
{
  const gchar *text;
  GtkPSFont *psfont;
  gboolean italic, bold;
  gint height; 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.