giada - new release

Jaromír Mikeš mira.mikes at gmail.com
Wed Jan 17 17:54:49 UTC 2018


2018-01-17 17:19 GMT+01:00 James Cowgill <jcowgill at debian.org>:

> Hi,
>
> On 17/01/18 15:42, Jaromír Mikeš wrote:
> > ​Hi,
> >
> > giada unfortunately fail to build on some archs ... I already informed
> > upstream but not answer yet.
> > Can someone look if fixing this is rather trivial or complicated.
> >
> > https://buildd.debian.org/status/package.php?p=giada
>
> The entire function for reference:
> > std::string gu_format(const char* format, ...)
> > {
> >       va_list args;
> >
> >       /* Compute the size of the new expanded string (i.e. with
> replacement taken
> >       into account). */
> >
> >       size_t size = vsnprintf(nullptr, 0, format, args);
> >
> >       /* Create a new temporary char array to hold the new expanded
> string. */
> >
> >       std::unique_ptr<char[]> tmp(new char[size]);
> >
> >       /* Fill the temporary string with the formatted data. */
> >
> >   va_start(args, format);
> >       vsprintf(tmp.get(), format, args);
> >   va_end(args);
> >
> >       return string(tmp.get(), tmp.get() + size - 1);
> > }
>
> This line (the one the error complains about) reads the uninitialized
> args and invokes undefined behavior:
> > size_t size = vsnprintf(nullptr, 0, format, args);
>
> It needs to be surrounded in va_start, va_end block.
>
> The second subtle error is that vsnprintf returns the size _excluding
> the null byte_. This will cause the vsprintf call to overflow the buffer
> by 1 byte.
>
> This might work (untested):
>  va_start(args, format);
>  size_t size = vsnprintf(nullptr, 0, format, args) + 1;
>  va_end(args);
>
> Some alternative implementations. The varardic template solution (the
> third one) is similar to this code (and the one I like the most):
> https://stackoverflow.com/questions/2342162/stdstring-
> formatting-like-sprintf


​Thank you James! Uploaded! Let's see.

mira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-multimedia-maintainers/attachments/20180117/70f564cd/attachment.html>


More information about the pkg-multimedia-maintainers mailing list