[PATCH 2/8] hex-escape: be more strict about the format while decoding

David Bremner david at tethera.net
Thu Apr 5 04:59:36 PDT 2012


Jani Nikula <jani at nikula.org> writes:

> On Thu, 05 Apr 2012 08:33:23 -0300, David Bremner <david at tethera.net> wrote:
>> 
>> > -	    if (len < 3)
>> > +	    if (!isxdigit ((unsigned char) p[1]) ||
>> > +		!isxdigit ((unsigned char) p[2]))
>> 
>> What happens if there are not two characters after the escape? Is this
>> relying on calling isxdigit on the null terminator?
>
> It is, and technically there's nothing wrong with that. Would you prefer
> explicit checks for '\0' in the if condition, for clarity? Or a comment
> about it?

I think a comment would do. Or the checks if you prefer.


More information about the notmuch mailing list