This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: avoid a potential wrap
authorDavid Mitchell <davem@iabyn.com>
Wed, 10 May 2017 14:27:49 +0000 (15:27 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:00 +0000 (09:11 +0100)
commitf712c9c902dc12404cc91a577c7986c8bd7db5bf
treeab6964d42e4c21047da7f4ed0a0684bc658e535b
parent196344c20348c6f1effb9b3dabcee6350d47fbff
Perl_sv_vcatpvfn_flags: avoid a potential wrap

In the floating-point hex (%a) code, it checks whether the requested
precision is smaller than the hex buf size. It does this by casting
(precis + 1) to signed. Since precis can be any user-supplied value,
this can wrap. Instead, cast the (buffer_length - 1) to unsigned, since
this is bounded to a small constant value > 1.

In practise this makes no difference currently, as a large precis will
have caused a malloc panic earlier anyway. But that might change in
future.
sv.c