diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-26 16:12:18 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-26 16:12:18 +0200 |
| commit | 2ffd4e4f1af16b17a286ff354603a717f5d828a5 (patch) | |
| tree | 99e2d4a7e2fde8e3abb027eb687901440750ee00 /src/Fl_Native_File_Chooser_MAC.mm | |
| parent | 53d9614adbb728fc4db983c9bb817c6eea870994 (diff) | |
Replace all calls to sprintf() by calls to snprintf().
Diffstat (limited to 'src/Fl_Native_File_Chooser_MAC.mm')
| -rw-r--r-- | src/Fl_Native_File_Chooser_MAC.mm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Fl_Native_File_Chooser_MAC.mm b/src/Fl_Native_File_Chooser_MAC.mm index 413ceda34..8439f32d0 100644 --- a/src/Fl_Native_File_Chooser_MAC.mm +++ b/src/Fl_Native_File_Chooser_MAC.mm @@ -334,7 +334,7 @@ void Fl_Quartz_Native_File_Chooser_Driver::parse_filter(const char *in) { // If user didn't specify a name, make one // if ( name[0] == '\0' ) { - sprintf(name, "%.*s Files", (int)sizeof(name)-10, wildcard); + snprintf(name, sizeof(name), "%.*s Files", (int)sizeof(name)-10, wildcard); } // APPEND NEW FILTER TO LIST if ( wildcard[0] ) { @@ -434,7 +434,8 @@ static char *prepareMacFilter(int count, const char *filter, char **patterns) { l += strlen(patterns[i]) + 3; } const char *p = filter; - char *q; q = new char[strlen(p) + l + 1]; + const int t_size = strlen(p) + l + 1; + char *q; q = new char[t_size]; const char *r, *s; char *t; t = q; @@ -445,7 +446,9 @@ static char *prepareMacFilter(int count, const char *filter, char **patterns) { if (s && s < r) { memcpy(q, p, s - p); q += s - p; - if (rank < count) { sprintf(q, " (%s)", patterns[rank]); q += strlen(q); } + if (rank < count) { + snprintf(q, t_size-(q-t), " (%s)", patterns[rank]); q += strlen(q); + } } else { memcpy(q, p, r - p); |
