In S_scan_const(), use my_snprintf() instead of my_sprintf().
authorNicholas Clark <nick@ccl4.org>
Tue, 30 Nov 2010 13:16:11 +0000 (13:16 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 30 Nov 2010 13:17:28 +0000 (13:17 +0000)
Paranoid linkers warn about using sprintf(), and rightly so.

toke.c

diff --git a/toke.c b/toke.c
index d2868c2..476b331 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3203,7 +3203,8 @@ S_scan_const(pTHX_ char *start)
                            /* Convert first code point to hex, including the
                             * boiler plate before it */
                            output_length =
-                               my_sprintf(hex_string, "\\N{U+%X", (unsigned int) uv);
+                               my_snprintf(hex_string, sizeof(hex_string),
+                                           "\\N{U+%X", (unsigned int) uv);
 
                            /* Make sure there is enough space to hold it */
                            d = off + SvGROW(sv, off
@@ -3227,7 +3228,8 @@ S_scan_const(pTHX_ char *start)
                                }
 
                                output_length =
-                                   my_sprintf(hex_string, ".%X", (unsigned int) uv);
+                                   my_snprintf(hex_string, sizeof(hex_string),
+                                               ".%X", (unsigned int) uv);
 
                                d = off + SvGROW(sv, off
                                                     + output_length