[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 1/5] util: add base64 decoding function
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 1/5] util: add base64 decoding function |
Date: |
Wed, 9 Dec 2015 08:18:20 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 12/09/2015 05:50 AM, Daniel P. Berrange wrote:
> On Tue, Dec 08, 2015 at 09:18:30AM -0700, Eric Blake wrote:
>> On 11/27/2015 09:30 AM, Daniel P. Berrange wrote:
>>> The standard glib provided g_base64_decode doesn't provide any
>>> kind of sensible error checking on its input. Add a QEMU custom
>>> wrapper qbase64_decode which can be used with untrustworthy
>>> input that can contain invalid base64 characters, embedded
>>> NUL characters, or not be NUL terminated at all.
>>>
>>> Signed-off-by: Daniel P. Berrange <address@hidden>
>>> ---
>>
>>> + uint8_t *actual = qbase64_decode(input,
>>> + input_len,
>>> + &len,
>>> + &err);
>>> +
>>> + g_assert(err != NULL);
>>
>> Could use &error_abort in the original call instead of a second check
>> for err != NULL; but that's cosmetic.
>
> Actually we can't use &error_abort, as we don't want the test
> function to abort on error as that would indicate test failure.
> We want to make sure the call completes & returns an error
> set without aborting.
Whoops; confusing it with g_assert(err == NULL). (Which is why I tend
to just do g_assert(err) or g_assert(!err) instead of having to think
about the comparison with NULL, oh well).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature