Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 0349c90d4b62bd118ee5936fc76574560236d490 1 parent 28b0b79
erikd authored

Showing 1 changed file with 15 additions and 4 deletions. Show diff stats Hide diff stats

  1. +15 4 src/sweep_sample.c
19 src/sweep_sample.c
@@ -1602,12 +1602,23 @@ sample_selection_insert_tmp_sel (sw_sample * s)
1602 1602 sw_sel * sel;
1603 1603
1604 1604 n = snprintf (buf, sizeof (buf), _("Insert selection ["));
1605   - n += snprint_time (buf+n, sizeof (buf)-n,
  1605 + if (n < sizeof (buf)) {
  1606 + n += snprint_time (buf+n, sizeof (buf)-n,
1606 1607 frames_to_time (format, s->tmp_sel->sel_start));
1607   - n += snprintf (buf+n, sizeof (buf)-n, " - ");
1608   - n += snprint_time (buf+n, sizeof (buf)-n,
  1608 + }
  1609 +
  1610 + if (n < sizeof (buf)) {
  1611 + n += snprintf (buf+n, sizeof (buf)-n, " - ");
  1612 + }
  1613 +
  1614 + if (n < sizeof (buf)) {
  1615 + n += snprint_time (buf+n, sizeof (buf)-n,
1609 1616 frames_to_time (format, s->tmp_sel->sel_end));
1610   - n += snprintf (buf+n, sizeof (buf)-n, "]");
  1617 + }
  1618 +
  1619 + if (n < sizeof (buf)) {
  1620 + n += snprintf (buf+n, sizeof (buf)-n, "]");
  1621 + }
1611 1622
1612 1623 g_mutex_lock (s->sounddata->sels_mutex);
1613 1624

0 comments on commit 0349c90

Please sign in to comment.
Something went wrong with that request. Please try again.