Skip to content

buffer overflow bug #182

@Hoppz

Description

@Hoppz

I connect to a Septentrio RTK, in the function GPSDriverSBF::sendMessageAndWaitForAck :

do {
	--offset; //overwrite the null-char
	int ret = read(reinterpret_cast<uint8_t *>(buf) + offset, sizeof(buf) - offset - 1, timeout);

	if (ret < 0) {
		// something went wrong when reading
		SBF_WARN("sbf read err");
		return false;
	}

	offset += ret;
	
	buf[offset++] = '\0';

	if (!found_response && strstr(buf, "$R: ") != nullptr) {
		//SBF_DEBUG("READ %d: %s", (int) offset, buf);
		found_response = true;
	}

	if (offset >= sizeof(buf)) {
		offset = 1;
	}

} while (time_started + 1000 * timeout > gps_absolute_time());

I get a runtime error:

Run-Time Check Failure #2 - Stack around the variable 'buf' was corrupted.

Can anyone tell is this a problem with my connection configuration or a problem with the code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions