[libvirt] [PATCH] syntax-check: forbid virBufferAsprintf with string literals
Ján Tomko
jtomko at redhat.com
Tue May 7 15:56:33 UTC 2013
On 05/07/2013 04:32 PM, Eric Blake wrote:
> On 05/07/2013 05:46 AM, Ján Tomko wrote:
>> ---
>> cfg.mk | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/cfg.mk b/cfg.mk
>> index 1d63bbd..06f89d1 100644
>> --- a/cfg.mk
>> +++ b/cfg.mk
>> @@ -490,6 +490,11 @@ sc_prohibit_virBufferAdd_with_string_literal:
>> halt='use virBufferAddLit, not virBufferAdd, with a string literal' \
>> $(_sc_search_regexp)
>>
>> +sc_prohibit_virBufferAsprintf_with_string_literal:
>> + @prohibit='\<virBufferAsprintf *\([^,]+, *"([^%"]|\")*"\)' \
> ^^^^^^^^^^^^^
> I think it's slightly tighter to write "([^%"\]|\\.|%%)*" to pick up all
> backslash sequences as well as literal % in a printf format, and so that
> a string that ends in a backslash ("foo\\") doesn't fail to find the
> closing ". But those are corner cases; as written you catch 99.99% of
> offending code.
>
>> + halt='use virBufferAddLit, not virBufferAsprintf, with a string literal' \
>> + $(_sc_search_regexp)
>
> ACK.
>
Thank you, I've added the change you proposed and pushed it.
Jan
More information about the libvir-list
mailing list