aboutsummaryrefslogtreecommitdiffstats
path: root/src/fig2.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-11-02 14:02:01 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-11-02 14:02:01 +0100
commit90101548ec43fd50ddc143eb0cbe99bdd0b47c6f (patch)
tree6a4a7eaa55a31a7d54eeb0c34ef9bf3ef4547b94 /src/fig2.cpp
parentea56f46c8f017ef98ae647abc99ceecba9dce1e1 (diff)
downloadetisnoop-90101548ec43fd50ddc143eb0cbe99bdd0b47c6f.tar.gz
etisnoop-90101548ec43fd50ddc143eb0cbe99bdd0b47c6f.tar.bz2
etisnoop-90101548ec43fd50ddc143eb0cbe99bdd0b47c6f.zip
Improve FIG0/13, add 0/7, avoid int overflows
Diffstat (limited to 'src/fig2.cpp')
-rw-r--r--src/fig2.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/fig2.cpp b/src/fig2.cpp
index 6346300..399d280 100644
--- a/src/fig2.cpp
+++ b/src/fig2.cpp
@@ -65,7 +65,7 @@ static void handle_ext_label_data_field(fig2_common_t& fig2, ensemble_database::
if (fig2.rfu() == 0) {
const uint8_t rfa = (f[0] & 0x0F);
r.msgs.push_back(strprintf("rfa=%d", rfa));
- const uint16_t char_flag = f[1] * 256 + f[2];
+ const uint16_t char_flag = read_u16_from_buf(f + 1);
r.msgs.push_back(strprintf("character flag=%04x", char_flag));
if (len_bytes <= 3) {
@@ -114,7 +114,7 @@ fig_result_t fig2_select(fig2_common_t& fig2, const display_settings_t &disp)
switch (fig2.ext()) {
case 0: // Ensemble label
{ // ETSI EN 300 401 8.1.13
- uint16_t eid = f[1] * 256 + f[2];
+ uint16_t eid = read_u16_from_buf(f + 1);
if (fig2.figlen <= header_length + fig2.identifier_len()) {
r.errors.push_back("FIG2 length error");
}
@@ -133,7 +133,7 @@ fig_result_t fig2_select(fig2_common_t& fig2, const display_settings_t &disp)
case 1: // Programme service label
{ // ETSI EN 300 401 8.1.14.1
- uint16_t sid = f[1] * 256 + f[2];
+ uint16_t sid = read_u16_from_buf(f + 1);
if (fig2.figlen <= header_length + fig2.identifier_len()) {
r.errors.push_back("FIG2 length error");
}
@@ -162,14 +162,10 @@ fig_result_t fig2_select(fig2_common_t& fig2, const display_settings_t &disp)
uint8_t pd = (f[1] & 0x80) >> 7;
uint8_t SCIdS = f[1] & 0x0F;
if (pd == 0) {
- sid = f[2] * 256 + \
- f[3];
+ sid = read_u16_from_buf(f + 2);
}
else {
- sid = f[2] * 256 * 256 * 256 + \
- f[3] * 256 * 256 + \
- f[4] * 256 + \
- f[5];
+ sid = read_u32_from_buf(f + 2);
}
if (fig2.figlen <= header_length + fig2.identifier_len()) {
r.errors.push_back("FIG2 length error");
@@ -204,10 +200,7 @@ fig_result_t fig2_select(fig2_common_t& fig2, const display_settings_t &disp)
case 5: // Data service label
{ // ETSI EN 300 401 8.1.14.2
- uint32_t sid = f[1] * 256 * 256 * 256 + \
- f[2] * 256 * 256 + \
- f[3] * 256 + \
- f[4];
+ uint32_t sid = read_u32_from_buf(f + 1);
if (fig2.figlen <= header_length + fig2.identifier_len()) {
r.errors.push_back("FIG2 length error");
@@ -242,15 +235,11 @@ fig_result_t fig2_select(fig2_common_t& fig2, const display_settings_t &disp)
pd = (f[1] & 0x80) >> 7;
SCIdS = f[1] & 0x0F;
if (pd == 0) {
- sid = f[2] * 256 + \
- f[3];
+ sid = read_u16_from_buf(f + 2);
xpadapp = f[4] & 0x1F;
}
else {
- sid = f[2] * 256 * 256 * 256 + \
- f[3] * 256 * 256 + \
- f[4] * 256 + \
- f[5];
+ sid = read_u32_from_buf(f + 2);
xpadapp = f[6] & 0x1F;
}