-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix reading 0 bits #246
base: master
Are you sure you want to change the base?
Fix reading 0 bits #246
Conversation
Can one of the admins verify this patch? |
ok to test |
@jmajnert, I see only 3 places in the code where an input of Line 137: If alignBits := 8 - ((pd.bitsOffset) & 0x7)
...
if val, err := pd.getBitsValue(alignBits); err != nil { Line 505: If byteLength, err := pd.getBitsValue(8)
...
mantissa, err := pd.getBitsValue(8 * uint(byteLength-1-1)) Line 617: If var rawLength uint
...
rawLength = uint(pd.bytes[pd.byteOffset])
...
rawLength = uint(tempLength)
rawLength++
...
if rawValue, err := pd.getBitsValue(rawLength * 8); err != nil { I think it would be better to understand where this issue is coming from. Can you please check whether the issue you are seeing is because of lines 505 or 617? @eroshiva @SeanCondon, what are your thoughts about this comment? |
The data was coming from Viavi simulator. I need to set up the environment to be able to reproduce. This may take a while |
Good point @gab-arrobo - I see a debug statement on line 615, so it should be easy to tell if 617 is the source. @jmajnert Maybe it is in previously capture logs? |
I found the logs (attached here). It's line 615 |
@jmajnert, can you please update your PR to accordingly address the issue before calling line 617? |
That would mean fixing how |
Not necessarily, for example in line 960, there is an |
You're proposing guarding against error conditions in multiple call sites instead of doing it once in the callee. |
I think the benefit is that it gives a more precise error message. |
@jmajnert, based on the logs you shared, the issue is because |
That's exactly what I meant! If the calculation in line 578 is incorrect, it should be fixed there. But I'm not an expert and I don't know how to fix it. If the calculation is correct, meaning that input data is malformed, then an |
So far I got these suggestions:
This gives us 3 PRs, they shouldn't be conflicting. Please choose your preferred way of fixing this problem |
I was getting errors where the decoder wanted to decode 0 bits as a field value and fell over. This change adds a graceful failure by emitting and error message