summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2017-10-15 09:33:22 +0200
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2017-10-21 20:08:39 +0100
commit17661fb1c2bdb3f4c7af40322c5694e9651dafff (patch)
tree0f4dfd339f839cf4ce96f9c13d5b8b47a8c1c58f /sv.c
parentaefb3fa072c057c13029faf2c7044bca8e0cc344 (diff)
downloadperl-17661fb1c2bdb3f4c7af40322c5694e9651dafff.tar.gz
Fix sv_vcatpvfn %s with precision on non-NUL-terminated strings
The precision parameter to %s can be used to print non-NUL-terminated strings, so use my_strnlen() to limit the length checking to the specified length.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sv.c b/sv.c
index 070a0c195e..ac1fb4d823 100644
--- a/sv.c
+++ b/sv.c
@@ -12376,7 +12376,10 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
if (args) {
eptr = va_arg(*args, char*);
if (eptr)
- elen = strlen(eptr);
+ if (has_precis)
+ elen = my_strnlen(eptr, precis);
+ else
+ elen = strlen(eptr);
else {
eptr = (char *)nullstr;
elen = sizeof nullstr - 1;