[gmime] fixed a buffer overrun in charset conversion code
- From: Jeffrey Stedfast <fejj src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gmime] fixed a buffer overrun in charset conversion code
- Date: Wed, 12 Aug 2009 15:19:59 +0000 (UTC)
commit cf1dd264a2f2e2d3e4fa17418d45c423cd14696e
Author: Jeffrey Stedfast <fejj gnome org>
Date: Wed Aug 12 11:18:55 2009 -0400
fixed a buffer overrun in charset conversion code
2009-08-12 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-utils.c (charset_convert): If iconv() fails, treat
conditions where outleft == 0 the same as if we had gotten an
E2BIG error (e.g. we need to grow the output buffer) so that we
don't overrun it while appending a '?' placeholder character.
ChangeLog | 9 +++-
gmime/gmime-filter-charset.c | 16 ++++---
gmime/gmime-utils.c | 9 +++-
mono/gmime-api.raw | 98 ++++++++++++++++++++++++++++++++++++------
4 files changed, 107 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bf53f09..85a0097 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-12 Jeffrey Stedfast <fejj novell com>
+
+ * gmime/gmime-utils.c (charset_convert): If iconv() fails, treat
+ conditions where outleft == 0 the same as if we had gotten an
+ E2BIG error (e.g. we need to grow the output buffer) so that we
+ don't overrun it while appending a '?' placeholder character.
+
2009-07-04 Jeffrey Stedfast <fejj novell com>
* configure.ac: Check for GpgME needed for S/MIME support.
@@ -286,7 +293,7 @@
simple arithmetic to update our stream->position on Windows since it
may do line-ending translation behind our backs. Call ftell() to get
our real position after reading or writing.
-
+
* gmime/gmime-stream-fs.c (stream_read, stream_write): Same idea.
* gmime/gmime-utils.c (mktime_utc): Fixed the Windows code-path.
diff --git a/gmime/gmime-filter-charset.c b/gmime/gmime-filter-charset.c
index 61f2def..d5c27e7 100644
--- a/gmime/gmime-filter-charset.c
+++ b/gmime/gmime-filter-charset.c
@@ -157,7 +157,8 @@ filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
* EILSEQ An invalid multibyte sequence has been encountered
* in the input.
*
- * What we do here is eat the invalid bytes in the sequence and continue
+ * What we do here is eat the invalid bytes in the sequence
+ * and continue.
*/
inbuf++;
@@ -167,9 +168,9 @@ filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
goto noop;
}
}
- } while (((int) inleft) > 0);
+ } while (inleft > 0);
- if (((int) inleft) > 0) {
+ if (inleft > 0) {
/* We've either got an E2BIG or EINVAL. Save the
remainder of the buffer as we'll process this next
time through */
@@ -230,7 +231,8 @@ filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,
* EILSEQ An invalid multibyte sequence has been encountered
* in the input.
*
- * What we do here is eat the invalid bytes in the sequence and continue
+ * What we do here is eat the invalid bytes in the sequence
+ * and continue.
*/
inbuf++;
@@ -245,10 +247,10 @@ filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,
*/
break;
- } else
+ } else {
goto noop;
-
- } while (((int) inleft) > 0);
+ }
+ } while (inleft > 0);
}
/* flush the iconv conversion */
diff --git a/gmime/gmime-utils.c b/gmime/gmime-utils.c
index 6505e61..60f0c75 100644
--- a/gmime/gmime-utils.c
+++ b/gmime/gmime-utils.c
@@ -1509,15 +1509,18 @@ charset_convert (iconv_t cd, const char *inbuf, size_t inleft, char **outp, size
errno = E2BIG;
#endif
- if (errno == E2BIG) {
+ if (errno == E2BIG || outleft == 0) {
/* need to grow the output buffer */
outlen += (inleft * 2) + 16;
rc = (size_t) (outbuf - out);
out = g_realloc (out, outlen + 1);
outleft = outlen - rc;
outbuf = out + rc;
- } else {
- /* invalid byte(-sequence) in the input buffer */
+ }
+
+ if (errno == EINVAL || errno == EILSEQ) {
+ /* invalid or incomplete multibyte
+ * sequence in the input buffer */
*outbuf++ = '?';
outleft--;
inleft--;
diff --git a/mono/gmime-api.raw b/mono/gmime-api.raw
index c9d1863..790fea4 100644
--- a/mono/gmime-api.raw
+++ b/mono/gmime-api.raw
@@ -1415,6 +1415,26 @@
<return-type type="gboolean" />
</method>
</object>
+ <object name="Pkcs7Context" cname="GMimePkcs7Context" parent="GMimeCipherContext">
+ <field name="Priv" cname="priv" type="struct-_GMimePkcs7ContextPrivate*" />
+ <method name="GetAlwaysTrust" cname="g_mime_pkcs7_context_get_always_trust">
+ <return-type type="gboolean" />
+ </method>
+ <method name="GetType" cname="g_mime_pkcs7_context_get_type" shared="true">
+ <return-type type="GType" />
+ </method>
+ <constructor cname="g_mime_pkcs7_context_new">
+ <parameters>
+ <parameter type="GMimePasswordRequestFunc" name="request_passwd" />
+ </parameters>
+ </constructor>
+ <method name="SetAlwaysTrust" cname="g_mime_pkcs7_context_set_always_trust">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="gboolean" name="always_trust" />
+ </parameters>
+ </method>
+ </object>
<object name="Stream" cname="GMimeStream" parent="GObject">
<field name="SuperStream" cname="super_stream" type="GMimeStream*" />
<field name="Position" cname="position" type="gint64" />
@@ -2574,33 +2594,53 @@
<field name="Status" cname="status" bits="2" type="unsigned int" access="public" writeable="true" />
<field name="Errors" cname="errors" bits="4" type="unsigned int" access="public" writeable="true" />
<field name="Trust" cname="trust" bits="3" type="unsigned int" access="public" writeable="true" />
- <field name="Unused" cname="unused" bits="23" type="unsigned int" access="public" writeable="true" />
+ <field name="Unused" cname="unused" bits="21" type="unsigned int" access="public" writeable="true" />
+ <field name="IssuerSerial" cname="issuer_serial" type="char*" access="public" writeable="true" />
+ <field name="IssuerName" cname="issuer_name" type="char*" access="public" writeable="true" />
<field name="Fingerprint" cname="fingerprint" type="char*" access="public" writeable="true" />
- <field name="Created" cname="created" type="time_t" access="public" writeable="true" />
- <field name="Expires" cname="expires" type="time_t" access="public" writeable="true" />
+ <field name="SigCreated" cname="sig_created" type="time_t" access="public" writeable="true" />
+ <field name="SigExpires" cname="sig_expires" type="time_t" access="public" writeable="true" />
+ <field name="KeyCreated" cname="key_created" type="time_t" access="public" writeable="true" />
+ <field name="KeyExpires" cname="key_expires" type="time_t" access="public" writeable="true" />
<field name="Keyid" cname="keyid" type="char*" access="public" writeable="true" />
+ <field name="Email" cname="email" type="char*" access="public" writeable="true" />
<field name="Name" cname="name" type="char*" access="public" writeable="true" />
<method name="Free" cname="g_mime_signer_free">
<return-type type="void" />
</method>
- <method name="GetCreated" cname="g_mime_signer_get_created">
- <return-type type="time_t" />
+ <method name="GetEmail" cname="g_mime_signer_get_email">
+ <return-type type="const-char*" />
</method>
<method name="GetErrors" cname="g_mime_signer_get_errors">
<return-type type="GMimeSignerError" />
</method>
- <method name="GetExpires" cname="g_mime_signer_get_expires">
- <return-type type="time_t" />
- </method>
<method name="GetFingerprint" cname="g_mime_signer_get_fingerprint">
<return-type type="const-char*" />
</method>
+ <method name="GetIssuerName" cname="g_mime_signer_get_issuer_name">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetIssuerSerial" cname="g_mime_signer_get_issuer_serial">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetKeyCreated" cname="g_mime_signer_get_key_created">
+ <return-type type="time_t" />
+ </method>
+ <method name="GetKeyExpires" cname="g_mime_signer_get_key_expires">
+ <return-type type="time_t" />
+ </method>
<method name="GetKeyId" cname="g_mime_signer_get_key_id">
<return-type type="const-char*" />
</method>
<method name="GetName" cname="g_mime_signer_get_name">
<return-type type="const-char*" />
</method>
+ <method name="GetSigCreated" cname="g_mime_signer_get_sig_created">
+ <return-type type="time_t" />
+ </method>
+ <method name="GetSigExpires" cname="g_mime_signer_get_sig_expires">
+ <return-type type="time_t" />
+ </method>
<method name="GetStatus" cname="g_mime_signer_get_status">
<return-type type="GMimeSignerStatus" />
</method>
@@ -2611,10 +2651,10 @@
<method name="Next" cname="g_mime_signer_next">
<return-type type="GMimeSigner*" />
</method>
- <method name="SetCreated" cname="g_mime_signer_set_created">
+ <method name="SetEmail" cname="g_mime_signer_set_email">
<return-type type="void" />
<parameters>
- <parameter type="time_t" name="created" />
+ <parameter type="const-char*" name="email" />
</parameters>
</method>
<method name="SetErrors" cname="g_mime_signer_set_errors">
@@ -2623,16 +2663,34 @@
<parameter type="GMimeSignerError" name="error" />
</parameters>
</method>
- <method name="SetExpires" cname="g_mime_signer_set_expires">
+ <method name="SetFingerprint" cname="g_mime_signer_set_fingerprint">
<return-type type="void" />
<parameters>
- <parameter type="time_t" name="expires" />
+ <parameter type="const-char*" name="fingerprint" />
</parameters>
</method>
- <method name="SetFingerprint" cname="g_mime_signer_set_fingerprint">
+ <method name="SetIssuerName" cname="g_mime_signer_set_issuer_name">
<return-type type="void" />
<parameters>
- <parameter type="const-char*" name="fingerprint" />
+ <parameter type="const-char*" name="issuer_name" />
+ </parameters>
+ </method>
+ <method name="SetIssuerSerial" cname="g_mime_signer_set_issuer_serial">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="issuer_serial" />
+ </parameters>
+ </method>
+ <method name="SetKeyCreated" cname="g_mime_signer_set_key_created">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="time_t" name="created" />
+ </parameters>
+ </method>
+ <method name="SetKeyExpires" cname="g_mime_signer_set_key_expires">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="time_t" name="expires" />
</parameters>
</method>
<method name="SetKeyId" cname="g_mime_signer_set_key_id">
@@ -2647,6 +2705,18 @@
<parameter type="const-char*" name="name" />
</parameters>
</method>
+ <method name="SetSigCreated" cname="g_mime_signer_set_sig_created">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="time_t" name="created" />
+ </parameters>
+ </method>
+ <method name="SetSigExpires" cname="g_mime_signer_set_sig_expires">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="time_t" name="expires" />
+ </parameters>
+ </method>
<method name="SetStatus" cname="g_mime_signer_set_status">
<return-type type="void" />
<parameters>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]