History

further serial snprintf bounds insurance

Ge Wang committed 3 years ago

Commit e690b7a1 parent a1e7e7b1 file · +3 −3Browse files

Showing the changes to src/core/util_serial.cpp (1 of 1 file). Show all

Unified · Split

src/core/util_serial.cpp+3−3
@@ -126,15 +126,15 @@ using namespace std; · 125 unmodified lines
126126 vector<string> SerialIOManager::availableSerialDevices()
127127 {
128128 vector<string> devices;
129− const int buf_size = 4096;
129+ const int buf_size = 4096+256;
130130 // was PATH_MAX;
131131 // which apparently isn't
132132 // https://stackoverflow.com/questions/9449241/where-is-path-max-defined-in-linux
133133 // https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
134134 // https://news.ycombinator.com/item?id=14194681
135135 const char * serial_dir = "/dev/serial/by-id";
136− char link_buf[buf_size+256]; // 1.5.0.1 (ge) added 256 for extra snprintf padding
137− char path_buf[buf_size];
136+ char link_buf[buf_size]; // 1.5.0.1 (ge) added 256 for extra snprintf padding
137+ char path_buf[buf_size-256];
138138
139139 DIR * dir = opendir(serial_dir);
140140

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t