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



2011/9/30 Dan Williams <dcbw redhat com>:
> 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?
>
I think my description is misleading since it's not a real corruption.
In reader.c:cert_parser():

if (   (array->len > strlen (SCHEME_PATH))
    && g_str_has_prefix ((const char *) array->data, SCHEME_PATH)
    && (array->data[array->len - 1] == '\0'))

The if statement checks whether '\0' is in the end of array. However,
this will never happen since get_uchar_array() never includes '\0'.

> 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?
>
OK, I will apply the fix and test again!

Thanks!

Gary Lin


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