Re: [PATCH] keyfile: include '\0' when copying string to array



On Fri, 2011-09-23 at 18:15 +0800, Gary Ching-Pang Lin wrote:
> This commit fixes the corrupted string in the copied array by
> including '\0' in the orignal string.

This function gets used for SSIDs too though, and they can't have a
trailing NULL.  So we need to add the NULL for certificates, but not add
it for SSIDs.  Can you be more specific about where the corruption was
happening and what the input data was that caused it?

In any case, there was one case which needed fixing, where obviously
using new-style plain strings, keyfile wouldn't hit the first case where
the string was already prefixed with the file:// scheme (since that code
checked for NULL termination).  I've pushed a rework of the code to fix
that and make it more apparent what's going on.  Can you check latest
git master to see if that change fixes your issue?

Dan

> ---
>  src/settings/plugins/keyfile/reader.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
> index c4136e0..451d01c 100644
> --- a/src/settings/plugins/keyfile/reader.c
> +++ b/src/settings/plugins/keyfile/reader.c
> @@ -759,8 +759,8 @@ get_uchar_array (GKeyFile *keyfile,
>  		g_regex_unref (regex);
>  
>  		if (new_format) {
> -			array = g_byte_array_sized_new (strlen (tmp_string));
> -			g_byte_array_append (array, (guint8 *) tmp_string, strlen (tmp_string));
> +			array = g_byte_array_sized_new (strlen (tmp_string) + 1);
> +			g_byte_array_append (array, (guint8 *) tmp_string, strlen (tmp_string) + 1);
>  		}
>  		g_free (tmp_string);
>  	}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]