Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible infinite loop in smlOBISByUnit() #36

Open
iaaby opened this issue Sep 29, 2024 · 0 comments
Open

Possible infinite loop in smlOBISByUnit() #36

iaaby opened this issue Sep 29, 2024 · 0 comments

Comments

@iaaby
Copy link

iaaby commented Sep 29, 2024

I have a setup where I do get quite a loot of checksum errors when reading my smart meter. The sml_parser library is also implemented in a way so that data is parsed on-the-fly, so before any checksum could have been checked.

I encountered once that my program was hanging. When attaching with the debugger it was in an infinite loop in smlOBISByUnit() function. Sadly, I did not do any further investigation. So I do not know what input data has caused this infinite loop.

When having a look at the implementation of smlOBISByUnit() I am wondering, if continuing the loop if "pos" is greater 6 makes any sense? So I updated my copy of sml_parser with the below patch which will make sure, it cannot get stuck in an endless loop anymore.

Any comments on it? All tests still pass.

diff --git a/sml.cpp b/sml.cpp
index 0edee97..c357653 100644
--- a/sml.cpp
+++ b/sml.cpp
@@ -367,6 +367,7 @@ void smlOBISByUnit(long long int &val, signed char &scaler, sml_units_t unit)
         // left shift received bytes to 64 bit signed integer
         val = (val << 8) | listBuffer[i + y];
       }
+      return;
     }
     i += size;
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant