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

Fixes for Android sound driver. #2457

Merged
merged 1 commit into from
Mar 4, 2022

Conversation

softins
Copy link
Member

@softins softins commented Mar 3, 2022

Short description of changes

Corrected a stray reference to float size, which should be int16_t,
and may have caused a buffer overflow in some circumstances.

Corrected a CodeQL multiplication overflow warning.

CHANGELOG: Android: Improve sound driver to fix CodeQL warnings

Context: Fixes an issue?

CodeQL warning and incorrect data size calculation found from code inspection.

Does this change need documentation? What needs to be documented and how?

No

Status of this Pull Request

Hopefully ready, but awaiting CI and local test

What is missing until this pull request can be merged?

Check the CI

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

Corrected a stray reference to float size, which should be int16_t,
and may have caused a buffer overflow in some circumstances.

Corrected a CodeQL multiplication overflow warning.

memcpy ( audioData, outBuffer.data(), count * sizeof ( int16_t ) );
memcpy ( intData, outBuffer.data(), sizeof ( int16_t ) * count );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that by putting sizeof(int16_t) first in the expression, it should correctly avoid overflow without count having to be of type std::size_t. Similarly a few lines further down.

@pljones
Copy link
Collaborator

pljones commented Mar 3, 2022

Tried installing this on my Moto G9 Power. 3.8.2rc1 installed OK. This one failed with a rather generic "Something went wrong" (joy of Android).

I'll see if the previous build worked.

@pljones
Copy link
Collaborator

pljones commented Mar 3, 2022

Nope, basically I have to uninstall and reinstall on Android. But it's nothing related to this.

@pljones
Copy link
Collaborator

pljones commented Mar 3, 2022

OK, installed and I can connect and listen, very nicely, to a server in Germany (with apologies for forgetting to turn on "Mute Myself").

They could hear me, I could hear them. (They could hear me more than they or I wanted, in fact...) I don't have Stereo 3.5mm + Mono 1/4" to Headset 2.5mm adaptor or I'd have tried that (just to say hello :) ).

@hoffie
Copy link
Member

hoffie commented Mar 3, 2022

Nope, basically I have to uninstall and reinstall on Android. But it's nothing related to this.

Yep, tracked in #1760.

@hoffie hoffie added this to the Release 3.9.0 milestone Mar 3, 2022
@softins
Copy link
Member Author

softins commented Mar 3, 2022

Great, I'll try it on my Android phone tomorrow and then un-draft it.

@pljones
Copy link
Collaborator

pljones commented Mar 4, 2022

Another idea before I forget to write it down...

It would be nice to have if the Android audio system could check whether it's only got the internal mic / audio out connected. If so, it should turn on "Mute Myself" and prevent it being turned off. (Maybe have a different banner - so we'd have "unmuted", "self-muted" and "hard muted".)

@softins
Copy link
Member Author

softins commented Mar 4, 2022

@pljones - good point, but it will get lost here, once this is closed. Could you reference the above comment in a separate issue?

@softins softins marked this pull request as ready for review March 4, 2022 12:34
@softins
Copy link
Member Author

softins commented Mar 4, 2022

Loaded the artifact on my phone (as before, needed to uninstall previous version first), and it appears to run as well as the previous version. So I think this is ready now.

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test it at the moment, but I'd assume it's allright? However, I don't see that the CodeQl warning is gone?

Copy link
Member

@hoffie hoffie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks sane to me. :)

@ann0see ann0see merged commit b2cb4a2 into jamulussoftware:master Mar 4, 2022
@ann0see
Copy link
Member

ann0see commented Mar 4, 2022

Ok. Merged it.

@softins
Copy link
Member Author

softins commented Mar 4, 2022

I can't test it at the moment, but I'd assume it's allright? However, I don't see that the CodeQl warning is gone?

The CodeQL entries under Security seem to persist, and show as either Fixed or Re-appeared, until their entries are deleted, I assume.

There also seems to be some erraticness in whether they are flagged or not. I have observed messages saying "Fixed in commit xxx" and "Re-appeared in commit yyy", but a comparison of those commits shows the code in question has not changed. ???

I've also found some more similar entries in my own fork that don't appear under the main repo, but looking at the code suggests they are valid. I'll audit them over the next few days and raise another PR for them.

@pljones
Copy link
Collaborator

pljones commented Mar 5, 2022

Yep, it seems erratic almost to the point of worthlessness - but not quite. It is labelled "beta"...

@ann0see
Copy link
Member

ann0see commented Jul 25, 2022

@pljones I've re written the changelog line a bit here too.

@softins softins deleted the android-sound-fixes branch August 30, 2023 17:29
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

Successfully merging this pull request may close these issues.

4 participants