Warn if the input is too short. (#418862, Halton Huo)

2007-03-16  Matthias Clasen  <mclasen@redhat.com>

        * glib/gbase64.c (g_base64_decode): Warn if the input
        is too short.  (#418862, Halton Huo)



svn path=/branches/glib-2-12/; revision=5418
This commit is contained in:
Matthias Clasen
2007-03-16 19:54:33 +00:00
committed by Matthias Clasen
parent a978934c2a
commit d62b406c38
2 changed files with 14 additions and 4 deletions

View File

@@ -1,3 +1,10 @@
2007-03-16 Matthias Clasen <mclasen@redhat.com>
Merge from trunk:
* glib/gbase64.c (g_base64_decode): Warn if the input
is too short. (#418862, Halton Huo)
2007-03-08 Matthias Clasen <mclasen@redhat.com>
* === Released 2.12.11 ===

View File

@@ -358,16 +358,19 @@ g_base64_decode (const gchar *text,
gsize *out_len)
{
guchar *ret;
gint inlen, state = 0;
gint input_length, state = 0;
guint save = 0;
g_return_val_if_fail (text != NULL, NULL);
g_return_val_if_fail (out_len != NULL, NULL);
inlen = strlen (text);
ret = g_malloc0 (inlen * 3 / 4);
input_length = strlen (text);
g_return_val_if_fail (input_length > 1, NULL);
ret = g_malloc0 (input_length * 3 / 4);
*out_len = g_base64_decode_step (text, inlen, ret, &state, &save);
*out_len = g_base64_decode_step (text, input_length, ret, &state, &save);
return ret;
}