diff --git a/ChangeLog b/ChangeLog index 0eb2d667..c7426e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-01-09 Nick Treleaven + + * src/utils.c, src/sci_cb.c, src/sciwrappers.c: + Prevent some possible buffer overflows. + + 2007-01-08 Enrico Tröger * doc/geany.docbook, src/keybindings.c, src/keybindings.h: diff --git a/src/sci_cb.c b/src/sci_cb.c index 163534ee..1905df42 100644 --- a/src/sci_cb.c +++ b/src/sci_cb.c @@ -259,7 +259,7 @@ void on_editor_notification(GtkWidget *editor, gint scn, gpointer lscn, gpointer { gint start, pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0); start = pos; - while (sci_get_char_at(sci, --start) != '&') ; + while (start > 0 && sci_get_char_at(sci, --start) != '&') ; SSM(sci, SCI_INSERTTEXT, pos - 1, (sptr_t) nt->text); } @@ -897,7 +897,7 @@ void sci_cb_auto_forif(gint idx, gint pos) sci_get_text_range(sci, pos - 16, pos - 1, buf); // check the first 8 characters of buf for whitespace, but only in this line i = 14; - while (isalpha(buf[i])) i--; // find pos before keyword + while (i >= 0 && isalpha(buf[i])) i--; // find pos before keyword while (i >= 0 && buf[i] != '\n' && buf[i] != '\r') // we want to stay in this line('\n' check) { if (! isspace(buf[i])) @@ -1177,7 +1177,7 @@ void sci_cb_auto_table(ScintillaObject *sci, gint pos) x = strlen(indent); // find the start of the 0 && isspace(sci_get_char_at(sci, end))) end--; start = end; c = 0;