[libvirt] [PATCH 4/5] phyp: Fix too small buffer allocation in phypAttachDevice

Eric Blake eblake at redhat.com
Thu Apr 14 16:49:49 UTC 2011


On 04/14/2011 06:00 AM, Matthias Bolte wrote:
>>  ACK, we just need to make sure contains_specialcharacters() and
>> escape_specialcharacters() don't diverge on the charater set. Maybe
>> add a comment in escape_specialcharacters() to this effect.
>>
>> Daniel
>>
> 
> I just moved the character set to a define, like this and pushed the result.
> 
> @@ -905,32 +911,10 @@ contains_specialcharacters(const char *src)
> 
>      for (i = 0; i < len; i++) {
>          switch (src[i]) {
> +        SPECIALCHARACTER_CASES
> +            return true;
> +        default:
> +            continue;
>          }

Fair enough - continue the loop until we find a special character.

>      }
> 
> @@ -954,35 +938,11 @@ escape_specialcharacters(const char *src)
> 
>      for (i = 0; i < len; i++) {
>          switch (src[i]) {
> +        SPECIALCHARACTER_CASES
> +            continue;
> +        default:
> +            dst[j] = src[i];
> +            j++;

Huh?  That is not escaping characters, but omitting them!  This code
seems rather broken; was the intent to add \ escaping before special
characters?

I _really_ want to add something to src/util/util.h that outputs
shell-escaped strings automatically (virCommandToString needs to use it,
and the current 'virsh echo --shell' could share it), so that all
clients that are doing shell escaping use a single entry point rather
than re-coding ad-hoc methods.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110414/33999d41/attachment-0001.sig>


More information about the libvir-list mailing list