On 8/4/18, Martin Sebor <mse...@gmail.com> wrote: > The sprintf handling of wide characters neglects to consider > that calling the function may fail due to a conversion error > (when the wide character is invalid or not representable in > the current locale). The handling also misinterprets > the POSIX %S wide string directive as a plain narrow %s and > doesn't include %C (the POSIX equivalent of %lc).
I was worried about portability to non-POSIX platforms, but after checking the documentation for the gnulib sprintf-posix module, apparently there are no portability issues with platforms that don't support the %C directive, so I guess it should be fine: https://www.gnu.org/software/gnulib/manual/html_node/sprintf.html > The attached patch corrects these oversights by extending the data > structures to indicate when a directive may fail, and extending the > UNDER4K member of the format_result structure to also encode > calls with such directives. > > Tested on x86_64-linux. > > Besides the trunk, since this bug can affect code correctness > I'd like to backport this patch to both release branches (7 > and 8). > > Martin >