Commits:
-
4ba545d1
by Werner Lemberg at 2023-05-23T13:19:05+02:00
Replace `sprintf` with `snprintf`.
* graph/x11/grx11.c (main), graph/xtest.c (main): Do it.
* src/ftsdf.c (BUFSIZE): New macro.
(write_header): Use `snprintf`.
* src/ftstring.c (write_header): Ditto.
* src/rsvg-port.c (rsvg_port_preset_slot): Ditto.
5 changed files:
Changes:
graph/x11/grx11.c
... |
... |
@@ -1586,7 +1586,7 @@ |
1586
|
1586
|
|
1587
|
1587
|
if ( !kname )
|
1588
|
1588
|
{
|
1589
|
|
- sprintf( kname_temp, "char '%c'", (char)event.key );
|
|
1589
|
+ snprintf( kname_temp, 16, "char '%c'", (char)event.key );
|
1590
|
1590
|
kname = kname_temp;
|
1591
|
1591
|
}
|
1592
|
1592
|
|
graph/xtest.c
... |
... |
@@ -110,7 +110,7 @@ int main( void ) |
110
|
110
|
|
111
|
111
|
if (!kname)
|
112
|
112
|
{
|
113
|
|
- sprintf( kname_temp, "char '%c'", (char)event.key );
|
|
113
|
+ snprintf( kname_temp, 16, "char '%c'", (char)event.key );
|
114
|
114
|
kname = kname_temp;
|
115
|
115
|
}
|
116
|
116
|
|
src/ftsdf.c
... |
... |
@@ -27,6 +27,9 @@ |
27
|
27
|
typedef FT_BBox Box;
|
28
|
28
|
|
29
|
29
|
|
|
30
|
+#define BUFSIZE 512
|
|
31
|
+
|
|
32
|
+
|
30
|
33
|
#define FT_CALL( X ) \
|
31
|
34
|
do \
|
32
|
35
|
{ \
|
... |
... |
@@ -219,46 +222,51 @@ |
219
|
222
|
static void
|
220
|
223
|
write_header( void )
|
221
|
224
|
{
|
222
|
|
- static char header_string[512];
|
|
225
|
+ static char header_string[BUFSIZE];
|
223
|
226
|
|
224
|
227
|
|
225
|
|
- sprintf( header_string,
|
226
|
|
- "Glyph Index: %d, Pt Size: %d, Spread: %d, Scale: %u",
|
227
|
|
- status.glyph_index,
|
228
|
|
- status.ptsize,
|
229
|
|
- status.spread,
|
230
|
|
- status.scale );
|
|
228
|
+ snprintf( header_string,
|
|
229
|
+ BUFSIZE,
|
|
230
|
+ "Glyph Index: %d, Pt Size: %d, Spread: %d, Scale: %u",
|
|
231
|
+ status.glyph_index,
|
|
232
|
+ status.ptsize,
|
|
233
|
+ status.spread,
|
|
234
|
+ status.scale );
|
231
|
235
|
grWriteCellString( display->bitmap, 0, 0,
|
232
|
236
|
header_string, display->fore_color );
|
233
|
237
|
|
234
|
|
- sprintf( header_string,
|
235
|
|
- "Position Offset: %d,%d",
|
236
|
|
- status.x_offset,
|
237
|
|
- status.y_offset );
|
|
238
|
+ snprintf( header_string,
|
|
239
|
+ BUFSIZE,
|
|
240
|
+ "Position Offset: %d,%d",
|
|
241
|
+ status.x_offset,
|
|
242
|
+ status.y_offset );
|
238
|
243
|
grWriteCellString( display->bitmap, 0, 1 * HEADER_HEIGHT,
|
239
|
244
|
header_string, display->fore_color );
|
240
|
245
|
|
241
|
|
- sprintf( header_string,
|
242
|
|
- "SDF Generated in: %.0f ms, From: %s",
|
243
|
|
- (double)status.generation_time,
|
244
|
|
- status.use_bitmap ? "Bitmap" : "Outline" );
|
|
246
|
+ snprintf( header_string,
|
|
247
|
+ BUFSIZE,
|
|
248
|
+ "SDF Generated in: %.0f ms, From: %s",
|
|
249
|
+ (double)status.generation_time,
|
|
250
|
+ status.use_bitmap ? "Bitmap" : "Outline" );
|
245
|
251
|
grWriteCellString( display->bitmap, 0, 2 * HEADER_HEIGHT,
|
246
|
252
|
header_string, display->fore_color );
|
247
|
253
|
|
248
|
|
- sprintf( header_string,
|
249
|
|
- "Filtering: %s, View: %s",
|
250
|
|
- status.nearest_filtering ? "Nearest" : "Bilinear",
|
251
|
|
- status.reconstruct ? "Reconstructing": "Raw" );
|
|
254
|
+ snprintf( header_string,
|
|
255
|
+ BUFSIZE,
|
|
256
|
+ "Filtering: %s, View: %s",
|
|
257
|
+ status.nearest_filtering ? "Nearest" : "Bilinear",
|
|
258
|
+ status.reconstruct ? "Reconstructing": "Raw" );
|
252
|
259
|
grWriteCellString( display->bitmap, 0, 3 * HEADER_HEIGHT,
|
253
|
260
|
header_string, display->fore_color );
|
254
|
261
|
|
255
|
262
|
if ( status.reconstruct )
|
256
|
263
|
{
|
257
|
264
|
/* Only print these in reconstruction mode. */
|
258
|
|
- sprintf( header_string,
|
259
|
|
- "Width: %.2f, Edge: %.2f",
|
260
|
|
- (double)status.width,
|
261
|
|
- (double)status.edge );
|
|
265
|
+ snprintf( header_string,
|
|
266
|
+ BUFSIZE,
|
|
267
|
+ "Width: %.2f, Edge: %.2f",
|
|
268
|
+ (double)status.width,
|
|
269
|
+ (double)status.edge );
|
262
|
270
|
grWriteCellString( display->bitmap, 0, 4 * HEADER_HEIGHT,
|
263
|
271
|
header_string, display->fore_color );
|
264
|
272
|
}
|
src/ftstring.c
... |
... |
@@ -669,7 +669,7 @@ |
669
|
669
|
-1, error_code );
|
670
|
670
|
|
671
|
671
|
/* describe kerning */
|
672
|
|
- x = sprintf( kern, "%s pairs, %s track",
|
|
672
|
+ x = snprintf( kern, 40, "%s pairs, %s track",
|
673
|
673
|
sc->kerning_mode == KERNING_MODE_SMART ? "adjusted" :
|
674
|
674
|
sc->kerning_mode == KERNING_MODE_NORMAL ? "" : "no",
|
675
|
675
|
sc->kerning_degree == KERNING_DEGREE_TIGHT ? "tight" :
|
src/rsvg-port.c
... |
... |
@@ -319,7 +319,7 @@ |
319
|
319
|
|
320
|
320
|
|
321
|
321
|
/* Render only the element with its ID equal to `glyph<ID>`. */
|
322
|
|
- sprintf( str + 6, "%u", slot->glyph_index );
|
|
322
|
+ snprintf( str + 6, 32 - 6, "%u", slot->glyph_index );
|
323
|
323
|
ret = rsvg_handle_render_cairo_sub( handle, rec_cr, str );
|
324
|
324
|
if ( ret == FALSE )
|
325
|
325
|
{
|
|