mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_HAL_Linux: Prevent buffer overflow
This commit is contained in:
parent
5d28fbfa1b
commit
86e335b6b6
@ -38,7 +38,7 @@ void AnalogSource_IIO::init_pins(void)
|
|||||||
for (int i=0; i < IIO_ANALOG_IN_COUNT; i++) {
|
for (int i=0; i < IIO_ANALOG_IN_COUNT; i++) {
|
||||||
// Construct the path by appending strings
|
// Construct the path by appending strings
|
||||||
strncpy(buf, IIO_ANALOG_IN_DIR, sizeof(buf));
|
strncpy(buf, IIO_ANALOG_IN_DIR, sizeof(buf));
|
||||||
strncat(buf, AnalogSource_IIO::analog_sources[i], sizeof(buf));
|
strncat(buf, AnalogSource_IIO::analog_sources[i], sizeof(buf) - strlen(buf) -1);
|
||||||
|
|
||||||
fd_analog_sources[i] = open(buf, O_RDONLY | O_NONBLOCK);
|
fd_analog_sources[i] = open(buf, O_RDONLY | O_NONBLOCK);
|
||||||
if (fd_analog_sources[i] == -1) {
|
if (fd_analog_sources[i] == -1) {
|
||||||
@ -79,7 +79,7 @@ void AnalogSource_IIO::reopen_pin(void)
|
|||||||
|
|
||||||
// Construct the path by appending strings
|
// Construct the path by appending strings
|
||||||
strncpy(buf, IIO_ANALOG_IN_DIR, sizeof(buf));
|
strncpy(buf, IIO_ANALOG_IN_DIR, sizeof(buf));
|
||||||
strncat(buf, AnalogSource_IIO::analog_sources[_pin], sizeof(buf));
|
strncat(buf, AnalogSource_IIO::analog_sources[_pin], sizeof(buf) - strlen(buf) - 1);
|
||||||
|
|
||||||
fd_analog_sources[_pin] = open(buf, O_RDONLY | O_NONBLOCK);
|
fd_analog_sources[_pin] = open(buf, O_RDONLY | O_NONBLOCK);
|
||||||
if (fd_analog_sources[_pin] == -1) {
|
if (fd_analog_sources[_pin] == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user