develooper Front page | perl.perl5.porters | Postings from June 2011

Broken API for is_utf8_char()

Thread Next
From:
Karl Williamson
Date:
June 29, 2011 15:02
Subject:
Broken API for is_utf8_char()
Message ID:
4E0BA0E9.6080801@khwilliamson.com
I was looking at Bug #32080 (Perl_is_utf8_string reads out of bounds), 
and have come to the conclusion that is_utf8_char() can't be fixed 
without changing the API.

The problem is that it takes a single parameter, a pointer to a buffer. 
  It looks at the first byte under the assumption that it is a valid 
utf8 character and from that calculates how many bytes that character 
should occupy.  But it then assumes that the buffer is large enough to 
contain all those bytes, which it may not be, and thus it can read 
beyond the end of the buffer.

It has no way of knowing how big the buffer is.  I propose changing the 
public interface to pass the buffer size.

The function is not called in cpan

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About