mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-20 00:47:52 +02:00
Modified Files: glib/ChangeLog glib/glib/giochannel.c
Modified Files: glib/ChangeLog glib/glib/giochannel.c * glib/giochannel.c: Matthias Clasen's fix for the buffer corruption bug by setting outbuf _after_ the call to g_string_set_size() * glib/giochannel.c: kept the buffers from perpetually growing by subtracting 1 from allocated_len in the calculation of available space to account for the null at the end of the buffer * glib/giochannel.c: fixed g_io_channel_write_chars() to not write more than space_in_buf bytes for the UTF-8 case
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1,3 +1,17 @@
|
|||||||
|
2001-08-24 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Matthias Clasen's fix for
|
||||||
|
the buffer corruption bug by setting outbuf _after_
|
||||||
|
the call to g_string_set_size()
|
||||||
|
|
||||||
|
* glib/giochannel.c: kept the buffers from perpetually
|
||||||
|
growing by subtracting 1 from allocated_len in the calculation
|
||||||
|
of available space to account for the null at the end of the
|
||||||
|
buffer
|
||||||
|
|
||||||
|
* glib/giochannel.c: fixed g_io_channel_write_chars()
|
||||||
|
to not write more than space_in_buf bytes for the UTF-8 case
|
||||||
|
|
||||||
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
Fri Aug 24 11:15:46 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
* glib/gstrfuncs.c docs/Changes-2.0.txt: Patch from Darin
|
||||||
|
@@ -1207,15 +1207,16 @@ g_io_channel_fill_buffer (GIOChannel *channel,
|
|||||||
reencode:
|
reencode:
|
||||||
|
|
||||||
inbytes_left = channel->read_buf->len;
|
inbytes_left = channel->read_buf->len;
|
||||||
outbytes_left = MAX (6, MAX (channel->read_buf->len,
|
outbytes_left = MAX (channel->read_buf->len,
|
||||||
channel->encoded_read_buf->allocated_len
|
channel->encoded_read_buf->allocated_len
|
||||||
- channel->encoded_read_buf->len));
|
- channel->encoded_read_buf->len - 1); /* 1 for NULL */
|
||||||
|
outbytes_left = MAX (outbytes_left, 6);
|
||||||
|
|
||||||
inbuf = channel->read_buf->str;
|
inbuf = channel->read_buf->str;
|
||||||
outbuf = channel->encoded_read_buf->str + channel->encoded_read_buf->len;
|
|
||||||
|
|
||||||
g_string_set_size (channel->encoded_read_buf,
|
g_string_set_size (channel->encoded_read_buf,
|
||||||
channel->encoded_read_buf->len + outbytes_left);
|
channel->encoded_read_buf->len + outbytes_left);
|
||||||
|
outbuf = channel->encoded_read_buf->str + channel->encoded_read_buf->len
|
||||||
|
- outbytes_left;
|
||||||
|
|
||||||
errnum = g_iconv (channel->read_cd, &inbuf, &inbytes_left,
|
errnum = g_iconv (channel->read_cd, &inbuf, &inbytes_left,
|
||||||
&outbuf, &outbytes_left);
|
&outbuf, &outbytes_left);
|
||||||
@@ -1958,8 +1959,8 @@ g_io_channel_write_chars (GIOChannel *channel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
space_in_buf = MAX (channel->buf_size, channel->write_buf->allocated_len)
|
space_in_buf = MAX (channel->buf_size, channel->write_buf->allocated_len - 1)
|
||||||
- channel->write_buf->len;
|
- channel->write_buf->len; /* 1 for NULL */
|
||||||
|
|
||||||
/* This is only true because g_io_channel_set_buffer_size ()
|
/* This is only true because g_io_channel_set_buffer_size ()
|
||||||
* ensures that channel->buf_size >= MAX_CHAR_SIZE.
|
* ensures that channel->buf_size >= MAX_CHAR_SIZE.
|
||||||
@@ -2002,17 +2003,18 @@ g_io_channel_write_chars (GIOChannel *channel,
|
|||||||
|
|
||||||
reconvert:
|
reconvert:
|
||||||
|
|
||||||
if (!channel->do_encode)
|
if (!channel->do_encode) /* UTF-8 encoding */
|
||||||
{
|
{
|
||||||
const gchar *badchar;
|
const gchar *badchar;
|
||||||
|
gsize try_len = MIN (from_buf_len, space_in_buf);
|
||||||
|
|
||||||
/* UTF-8, just validate, emulate g_iconv */
|
/* UTF-8, just validate, emulate g_iconv */
|
||||||
|
|
||||||
if (!g_utf8_validate (from_buf, from_buf_len, &badchar))
|
if (!g_utf8_validate (from_buf, try_len, &badchar))
|
||||||
{
|
{
|
||||||
gunichar try_char;
|
gunichar try_char;
|
||||||
|
|
||||||
left_len = from_buf + from_buf_len - badchar;
|
left_len = from_buf + try_len - badchar;
|
||||||
|
|
||||||
try_char = g_utf8_get_char_validated (badchar, left_len);
|
try_char = g_utf8_get_char_validated (badchar, left_len);
|
||||||
|
|
||||||
@@ -2020,16 +2022,27 @@ reconvert:
|
|||||||
{
|
{
|
||||||
case -2:
|
case -2:
|
||||||
g_assert (left_len < 6);
|
g_assert (left_len < 6);
|
||||||
errnum = EINVAL;
|
if (try_len == from_buf_len)
|
||||||
|
{
|
||||||
|
errnum = EINVAL;
|
||||||
|
err = (size_t) -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errnum = 0;
|
||||||
|
err = (size_t) -1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
|
g_warning ("Invalid UTF-8 passed to g_io_channel_write_chars().");
|
||||||
|
/* FIXME bail here? */
|
||||||
errnum = EILSEQ;
|
errnum = EILSEQ;
|
||||||
|
err = (size_t) -1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
errnum = 0; /* Don't confunse the compiler */
|
errnum = 0; /* Don't confunse the compiler */
|
||||||
}
|
}
|
||||||
err = (size_t) -1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2039,17 +2052,18 @@ reconvert:
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_string_append_len (channel->write_buf, from_buf,
|
g_string_append_len (channel->write_buf, from_buf,
|
||||||
from_buf_len - left_len);
|
try_len - left_len);
|
||||||
from_buf += from_buf_len - left_len;
|
from_buf += try_len - left_len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *outbuf;
|
gchar *outbuf;
|
||||||
|
|
||||||
left_len = from_buf_len;
|
left_len = from_buf_len;
|
||||||
outbuf = channel->write_buf->str + channel->write_buf->len;
|
|
||||||
g_string_set_size (channel->write_buf, channel->write_buf->len
|
g_string_set_size (channel->write_buf, channel->write_buf->len
|
||||||
+ space_in_buf);
|
+ space_in_buf);
|
||||||
|
outbuf = channel->write_buf->str + channel->write_buf->len
|
||||||
|
- space_in_buf;
|
||||||
err = g_iconv (channel->write_cd, (gchar **) &from_buf, &left_len,
|
err = g_iconv (channel->write_cd, (gchar **) &from_buf, &left_len,
|
||||||
&outbuf, &space_in_buf);
|
&outbuf, &space_in_buf);
|
||||||
errnum = errno;
|
errnum = errno;
|
||||||
|
Reference in New Issue
Block a user