Permalink
Browse files

src/sweep_sample.c : Fix potentially dangerous usage of snprintf.

git-svn-id: http://svn.metadecks.org/sweep/trunk@692 e2d53364-18fc-0310-981e-b60a84739af0
  • Loading branch information...
1 parent 28b0b79 commit 0349c90d4b62bd118ee5936fc76574560236d490 erikd committed Dec 29, 2009
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/sweep_sample.c
View
19 src/sweep_sample.c
@@ -1602,12 +1602,23 @@ sample_selection_insert_tmp_sel (sw_sample * s)
sw_sel * sel;
n = snprintf (buf, sizeof (buf), _("Insert selection ["));
- n += snprint_time (buf+n, sizeof (buf)-n,
+ if (n < sizeof (buf)) {
+ n += snprint_time (buf+n, sizeof (buf)-n,
frames_to_time (format, s->tmp_sel->sel_start));
- n += snprintf (buf+n, sizeof (buf)-n, " - ");
- n += snprint_time (buf+n, sizeof (buf)-n,
+ }
+
+ if (n < sizeof (buf)) {
+ n += snprintf (buf+n, sizeof (buf)-n, " - ");
+ }
+
+ if (n < sizeof (buf)) {
+ n += snprint_time (buf+n, sizeof (buf)-n,
frames_to_time (format, s->tmp_sel->sel_end));
- n += snprintf (buf+n, sizeof (buf)-n, "]");
+ }
+
+ if (n < sizeof (buf)) {
+ n += snprintf (buf+n, sizeof (buf)-n, "]");
+ }
g_mutex_lock (s->sounddata->sels_mutex);

0 comments on commit 0349c90

Please sign in to comment.