summaryrefslogtreecommitdiff
path: root/gr-blocks/lib/file_source_impl.cc
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2020-01-20 15:12:06 +0000
committermormj <34754695+mormj@users.noreply.github.com>2020-01-20 21:39:42 -0500
commit458ff8d6278b2bc62ad5f4cb7fbcd4fcaab66d9f (patch)
tree8593ba380d74a25b489913ae87c9192ab13fd8e0 /gr-blocks/lib/file_source_impl.cc
parentf9ccbe9f6f9f5994574db3e5f84baad7b3af7037 (diff)
blocks/file_source: Check for fseek() failing
Found by coverity. CID: * 1395913 * 1395940
Diffstat (limited to 'gr-blocks/lib/file_source_impl.cc')
-rw-r--r--gr-blocks/lib/file_source_impl.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/gr-blocks/lib/file_source_impl.cc b/gr-blocks/lib/file_source_impl.cc
index ee8f08d980..cfb1960d2a 100644
--- a/gr-blocks/lib/file_source_impl.cc
+++ b/gr-blocks/lib/file_source_impl.cc
@@ -162,7 +162,9 @@ void file_source_impl::open(const char* filename,
if (d_seekable) {
// Check to ensure the file will be consumed according to item size
- GR_FSEEK(d_new_fp, 0, SEEK_END);
+ if (GR_FSEEK(d_new_fp, 0, SEEK_END) == -1) {
+ throw std::runtime_error("can't fseek()");
+ }
file_size = GR_FTELL(d_new_fp);
// Make sure there will be at least one item available
@@ -198,7 +200,9 @@ void file_source_impl::open(const char* filename,
// Rewind to start offset
if (d_seekable) {
- GR_FSEEK(d_new_fp, start_offset_items * d_itemsize, SEEK_SET);
+ if (GR_FSEEK(d_new_fp, start_offset_items * d_itemsize, SEEK_SET) == -1) {
+ throw std::runtime_error("can't fseek()");
+ }
}
d_updated = true;
@@ -281,7 +285,9 @@ int file_source_impl::work(int noutput_items,
// Repeat: rewind and request tag
if (d_repeat && d_seekable) {
- GR_FSEEK(d_fp, d_start_offset_items * d_itemsize, SEEK_SET);
+ if (GR_FSEEK(d_fp, d_start_offset_items * d_itemsize, SEEK_SET) == -1) {
+ throw std::runtime_error("can't fseek()");
+ }
d_items_remaining = d_length_items;
if (d_add_begin_tag != pmt::PMT_NIL) {
d_file_begin = true;