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

PortInit_t index - possible issue (crash) #36

Open
SiMet opened this issue Nov 24, 2020 · 0 comments
Open

PortInit_t index - possible issue (crash) #36

SiMet opened this issue Nov 24, 2020 · 0 comments

Comments

@SiMet
Copy link
Contributor

SiMet commented Nov 24, 2020

Hi,

I was investigating random crash in our application and found that in daemon_cl.cpp we initialize
portInit.index = 0; and this value is ussed to register port in clock:

void registerPort(CommonPort* port, uint16_t index) {
		if (index < MAX_PORTS) {
			port_list[index - 1] = port;
		}
		++number_ports;
	}

This cause that we modify port_list at index '-1' and increase number_ports.
In constructor I set all port_list to the NULL which help me to found this issue.

After that port_list is used in CommonPort::processStateChange(Event e)

Here we try to get some values from port which was registered in the wrong way.
If there is NULL j index is 33 and we get some garbage values. If port_list was not initialized with NULLs we also get some garbage. Here we get the crash.

Potential fixes is to not allow to registerPort with index less then 1 or do not substract 1.

I'll be very glad to get some feedback if this is the issue of the daemon_cl sample.

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