mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 23:58:54 +02:00
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=/trunk/; revision=5417
This commit is contained in:
committed by
Matthias Clasen
parent
44d5b8af2a
commit
c182fecfa1
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user