diff options
author | Robin Gareus <robin@gareus.org> | 2012-10-26 03:11:10 +0000 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2012-10-26 03:11:10 +0000 |
commit | 6f5384879c2aa4bc3be78a5a92e80777dfccd4ed (patch) | |
tree | c7b407ed1c5a3c1d46e732a748c9a219b6c1a3da | |
parent | 4f698d6a54aa0f728e59efaef0c5adb2fd4ec64a (diff) |
prevent raptor attacks on Ardour's lead developer.
https://xkcd.com/292/
git-svn-id: svn://localhost/ardour2/branches/3.0@13345 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/ardour/session.h | 2 | ||||
-rw-r--r-- | libs/ardour/session_ltc.cc | 39 |
2 files changed, 14 insertions, 27 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index e3376ae45f..33fadcd6bd 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1203,7 +1203,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void ltc_tx_cleanup(); void ltc_tx_reset(); void ltc_tx_recalculate_position(); - int ltc_tx_send_time_code_for_cycle (framepos_t, framepos_t, double, double, pframes_t nframes); + void ltc_tx_send_time_code_for_cycle (framepos_t, framepos_t, double, double, pframes_t nframes); #endif void reset_record_status (); diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc index 6e3762592a..0cff7ef2b2 100644 --- a/libs/ardour/session_ltc.cc +++ b/libs/ardour/session_ltc.cc @@ -101,7 +101,7 @@ Session::ltc_tx_recalculate_position() ); } -int +void Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end_frame, double target_speed, double current_speed, pframes_t nframes) @@ -111,13 +111,11 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end Sample *out; pframes_t txf = 0; boost::shared_ptr<Port> ltcport = ltc_output_port(); - int ret = -1; Buffer& buf (ltcport->get_buffer (nframes)); if (!ltc_encoder || !ltc_enc_buf) { - ret = nframes; - goto out; + return; } SyncSource sync_src = Config->get_sync_source(); @@ -132,8 +130,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end */ (config.get_external_sync() && sync_src == MIDIClock) ) { - ret = nframes; - goto out; + return; } out = dynamic_cast<AudioBuffer*>(&buf)->data (); @@ -166,8 +163,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end if (ltc_encoder_reinit(ltc_encoder, nominal_frame_rate(), timecode_to_frames_per_second(cur_timecode), 0)) { PBD::error << _("LTC encoder: invalid framerate - LTC encoding is disabled for the remainder of this session.") << endmsg; ltc_tx_cleanup(); - ret = 0; - goto out; + return; } ltc_enc_tcformat = cur_timecode; ltc_tx_reset(); @@ -175,8 +171,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end /* LTC is max. 30 fps */ if (timecode_to_frames_per_second(cur_timecode) > 30) { - ret = nframes; - goto out; + return; } // (2) speed & direction @@ -233,16 +228,14 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end new_ltc_speed = 0; if (!Config->get_ltc_send_continuously()) { ltc_speed = new_ltc_speed; - ret = nframes; - goto out; + return; } } if (fabs(new_ltc_speed) > 10.0) { DEBUG_TRACE (DEBUG::LTC, "LTC TX2: speed is out of bounds.\n"); ltc_tx_reset(); - ret = nframes; - goto out; + return; } if (ltc_speed == 0 && new_ltc_speed != 0) { @@ -430,9 +423,8 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end memset(out, 0, cyc_off * sizeof(Sample)); } else { /* resync next cycle */ - memset(out, 0, cyc_off * sizeof(Sample)); - ret = frames; - goto done; + memset(out, 0, nframes * sizeof(Sample)); + return; } ltc_enc_pos = tc_sample_start; @@ -460,8 +452,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end if (txf >= nframes) { DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX7 enc: %1 [ %2 / %3 ] byte: %4 spd %5 fpp %6 || nf: %7\n", ltc_enc_pos, ltc_buf_off, ltc_buf_len, ltc_enc_byte, ltc_speed, nframes, txf)); - ret = nframes; - goto done; + break; } ltc_buf_len = 0; @@ -482,7 +473,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end DEBUG_TRACE (DEBUG::LTC, string_compose("LTC TX6.3 encoder error byte %1\n", ltc_enc_byte)); ltc_encoder_buffer_flush(ltc_encoder); ltc_tx_reset(); - goto out; + return; } int enc_frames = ltc_encoder_get_buffer(ltc_encoder, &(ltc_enc_buf[ltc_buf_len])); #ifdef LTC_GEN_FRAMEDBUG @@ -492,7 +483,7 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end DEBUG_TRACE (DEBUG::LTC, "LTC TX6.3 encoder empty buffer.\n"); ltc_encoder_buffer_flush(ltc_encoder); ltc_tx_reset(); - goto out;; + return; } ltc_buf_len += enc_frames; @@ -516,10 +507,6 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end #endif } - done: dynamic_cast<AudioBuffer*>(&buf)->set_written (true); - ret = nframes; - - out: - return ret; + return; } |