[gedit] Make sure to avoid buffer overflows when saving.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Make sure to avoid buffer overflows when saving.
- Date: Mon, 29 Mar 2010 19:49:16 +0000 (UTC)
commit bd6018993db15140139d592b1370a05238f95219
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Mar 29 21:06:03 2010 +0200
Make sure to avoid buffer overflows when saving.
Fixes bug #614205
gedit/gedit-document-input-stream.c | 14 ++++++++++++--
gedit/gedit-gio-document-saver.c | 4 ++++
2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-document-input-stream.c b/gedit/gedit-document-input-stream.c
index 45cba7e..c3b7179 100644
--- a/gedit/gedit-document-input-stream.c
+++ b/gedit/gedit-document-input-stream.c
@@ -330,9 +330,19 @@ read_line (GeditDocumentInputStream *stream,
while (written < to_write)
{
+ gint w;
+
ptr = g_utf8_next_char (ptr);
- written = (ptr - buf);
- ++char_offset;
+ w = (ptr - buf);
+ if (w > to_write)
+ {
+ break;
+ }
+ else
+ {
+ written = w;
+ ++char_offset;
+ }
}
memcpy (outbuf, buf, written);
diff --git a/gedit/gedit-gio-document-saver.c b/gedit/gedit-gio-document-saver.c
index 7830c58..52dbd7c 100644
--- a/gedit/gedit-gio-document-saver.c
+++ b/gedit/gedit-gio-document-saver.c
@@ -354,6 +354,8 @@ write_file_chunk (AsyncData *async)
{
GeditGioDocumentSaver *gvsaver;
+ gedit_debug (DEBUG_SAVER);
+
gvsaver = async->saver;
g_output_stream_write_async (G_OUTPUT_STREAM (gvsaver->priv->stream),
@@ -372,6 +374,8 @@ read_file_chunk (AsyncData *async)
GeditDocumentInputStream *dstream;
GError *error = NULL;
+ gedit_debug (DEBUG_SAVER);
+
gvsaver = async->saver;
async->written = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]