[vdr] trouble with asprintf
Klaus.Schmidinger at cadsoft.de
Sun Feb 10 16:15:39 CET 2008
On 02/10/08 16:06, Wolfgang Rohdewald wrote:
> I am making the muggle plugin work with UTF-8 and have a little problem:
> since asprintf leads to segfaults if feeded with incorrect UTF-8 characters,
> I wanted to write a wrapper function which would then check the return value
> of asprintf. However I have a problem with the variable argument list and
> the va_* macros. Using gdb shows that, in the following example, in
> res=asprintf (strp, fmt, ap);
> ap is interpreted not as a list of arguments but as an integer.
> What is wrong here?
> BTW I am quite sure that vdr will sometimes coredump since it never checks the
> return value of asprintf. One suspect would be if somebody used a latin1
> charset and had special characters like äöü in file names and then changes
> to utf-8 without converting file names to utf-8. If vdr then passes such
> a file name to asprintf, corrupted memory results. Might be difficult
> to debug remotely.
You could use VDR's cString::sprintf() instead.
This is probably also what I am going to do in the VDR core code,
to avoid asprintf() altogether. The single leftover vasprintf()
call in cString::sprintf() can then be made safe.
More information about the vdr