-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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] possible stack smashing #10048
base: master
Are you sure you want to change the base?
Conversation
It's not an issue for It could be an issue for |
For now. Later someone might add more messages expecting it to be already taken care of. I still believe it is needed to limit the increment to avoid future problems. |
If it is needed or not, the macro defined in random places is not great. Also, using the modulus operator (%) probably would be better than having that ternary operator. |
The macro is undefined at the end of the function, no problems here. Modulo would work but it will roll over and start overwriting old messages. Isn't it better to just stop adding new messages? |
Surely it's up to the developer to ensure they've checked that any additional messages added don't cause problems the same as with any other changes.
But that's one of the problems with this. More important messages may end up not being shown because the queue is full. Surely it's better to configure the messages so no more than the max allowed can be selected with more important messages prioritised. Admittedly |
My 2 Cents. The if the message array is full. No new messages should be added. The problem is then prioritising the order so that important messages are added first. |
I tested and found modulo produces somewhat larger code. Neither option gets 10 points for code clarity. |
While there is some truth to that, IMHO this code / style is a trap. A trap that has already caught us - there are already (many) more messages than the array size. IMHO we should not knowingly add traps to the code when those traps can be avoided. We could try to stop falling into this trap over and over, or we could remove the trap. |
This is not safe:
in functions osdGetSystemMessage() and osdGetMultiFunctionMessage() (osd.c)