changeset 3084:e02b6092f70e

gio: handle ungetc() stack accesses larger than size (e.g. support size * nmemb as it should be)
author William Pitcock <nenolod@atheme.org>
date Wed, 29 Apr 2009 20:21:31 -0500
parents 01d2f931aeeb
children ac0af6b39272
files src/gio/gio.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/gio/gio.c	Wed Apr 29 20:09:59 2009 -0500
+++ b/src/gio/gio.c	Wed Apr 29 20:21:31 2009 -0500
@@ -109,6 +109,7 @@
 {
     VFSGIOHandle *handle;
     goffset count = 0;
+    gsize realsize = (size * nmemb);
 
     g_return_val_if_fail(file != NULL, EOF);
     g_return_val_if_fail(file->handle != NULL, EOF);
@@ -119,7 +120,7 @@
     if (handle->stream_stack != NULL)
     {
         guchar uc;
-        while ((count < size) && (handle->stream_stack != NULL))
+        while ((count < realsize) && (handle->stream_stack != NULL))
         {
             uc = GPOINTER_TO_INT(handle->stream_stack->data);
             handle->stream_stack = g_slist_delete_link(handle->stream_stack, handle->stream_stack);
@@ -128,7 +129,7 @@
         }
     }
 
-    return g_input_stream_read(G_INPUT_STREAM(handle->istream), (ptr + count), ((size * nmemb) - count), NULL, NULL);
+    return g_input_stream_read(G_INPUT_STREAM(handle->istream), (ptr + count), (realsize - count), NULL, NULL);
 }
 
 size_t