summaryrefslogtreecommitdiff
path: root/pod/perlhacktips.pod
diff options
context:
space:
mode:
authorAaron Crane <arc@cpan.org>2017-11-18 18:07:23 +0000
committerAaron Crane <arc@cpan.org>2017-11-18 18:29:51 +0000
commit4059ba8734da3986285ad50019afbd56b586ad25 (patch)
tree72f2d7f4f78af14973ad71527d7d1aef141f00ff /pod/perlhacktips.pod
parentbd1f84ac544f5604940057502e2035f39c92bd4e (diff)
downloadperl-4059ba8734da3986285ad50019afbd56b586ad25.tar.gz
Restore ability to build on platforms without snprintf()
C89 does not in fact define snprintf() or vsnprintf(), and we must therefore probe for the existence of those functions before trying to use them. khw++ for pointing out my earlier error. This reverts part or all of each of the following commits: 13d66b05c6163c3514774d3d11da5f3950e97e98 Rely on C89 vsnprintf() e791399041815a1a45cea3c7f277c7045b96e51b Rely on C89 snprintf() adf7d503e55721c500f0bf66560b8f5df7966fe7 pod/perlhacktips.pod: remove some outdated portability notes
Diffstat (limited to 'pod/perlhacktips.pod')
-rw-r--r--pod/perlhacktips.pod16
1 files changed, 14 insertions, 2 deletions
diff --git a/pod/perlhacktips.pod b/pod/perlhacktips.pod
index a32997153f..cbf1d3c9f6 100644
--- a/pod/perlhacktips.pod
+++ b/pod/perlhacktips.pod
@@ -652,6 +652,10 @@ malloc(0), realloc(0), calloc(0, 0) are non-portable. To be portable
allocate at least one byte. (In general you should rarely need to work
at this low level, but instead use the various malloc wrappers.)
+=item *
+
+snprintf() - the return type is unportable. Use my_snprintf() instead.
+
=back
=head2 Security problems
@@ -685,12 +689,20 @@ domain implementation of INN).
Do not use sprintf() or vsprintf()
-If you really want just plain byte strings, use snprintf() and
-vsnprintf() instead. If you want something
+If you really want just plain byte strings, use my_snprintf() and
+my_vsnprintf() instead, which will try to use snprintf() and
+vsnprintf() if those safer APIs are available. If you want something
fancier than a plain byte string, use
L<C<Perl_form>()|perlapi/form> or SVs and
L<C<Perl_sv_catpvf()>|perlapi/sv_catpvf>.
+Note that glibc C<printf()>, C<sprintf()>, etc. are buggy before glibc
+version 2.17. They won't allow a C<%.s> format with a precision to
+create a string that isn't valid UTF-8 if the current underlying locale
+of the program is UTF-8. What happens is that the C<%s> and its operand are
+simply skipped without any notice.
+L<https://sourceware.org/bugzilla/show_bug.cgi?id=6530>.
+
=item *
Do not use atoi()