Commit 25ade82
committed
strlcpy chain conversions to strlcpy_append (continued)
Apply strlcpy_append (commit 78c52ab) to three further sites
identified in the wider strlcpy-misuse sweep, all with the
same shape that drove the prior commits c41e955 / 78c52ab /
e446242:
_len = strlcpy(buf, src1, sizeof(buf));
_len += strlcpy(buf + _len, src2, sizeof(buf) - _len);
... (more steps) ...
That chain is unsafe because strlcpy returns strlen(source)
regardless of truncation; on overflow _len overshoots
sizeof(buf) and the next sizeof - _len underflows size_t,
producing an unbounded copy that writes past the buffer.
Sites:
gfx/drivers/gl2.c:4549 - GL device-info string assembly.
gl->device_str is 128 bytes; the chain appends `vendor`,
' ', and `renderer` (all from glGetString). Some drivers
report long vendor/renderer combinations. Not attacker-
reachable in the usual threat model but the pattern is
still wrong, and the `device_str[_len]=' '; device_str
[++_len]='\0'` separator chain in the middle was the
short-chain shape from commit e446242.
menu/menu_displaylist.c:2767 - create_string_list_rdb_entry
_string. Builds out_lbl (NAME_MAX_LENGTH bytes) from
label + "|" + actual_string + "|" + path, plus tmp (128
bytes) from desc + ": " + actual_string. The strings
come from RetroArch database (.rdb) entries; a malicious
.rdb could supply long values to drive the chain
underflow. Modest threat model -- users typically use
the RetroArch-shipped databases, not custom ones -- but
the pattern is the same one we've fixed elsewhere.
command.c:1119 - GET_STATUS network reply. Builds the
reply for the network command interface from the paused/
playing state, system_id or library_name, content
basename, and CRC. reply is 8192 bytes which fits any
realistic content, but ROM basenames can legally be any
length and the chain has 8 steps; a long enough basename
drives the underflow.
Replace each chain with sequences of strlcpy_append calls
on a single rolling cursor. Same correctness story as
e446242: helper handles the bound check at every step,
truncation is silent and contained, no behaviour change
for the buffer-fits-comfortably case.
No new tests -- the strlcpy_append regression test from
78c52ab covers the helper's contract; these are additional
users.
Triaged but not fixed in this commit (safe by construction,
flagged for the record):
network/cloud_sync/webdav.c:401 - 16-call chain, but
the function pre-calculates the exact required length
via strlen() over the same inputs and mallocs that
exact size before the chain runs. Single-threaded.
retroarch.c:8769 - 20-call chain for SIMD feature names
into a 128-byte buffer. Total max ~120 bytes; tight but
no real CPU has all SIMD bits set so practical max is
well under cap.
gfx/video_shader_parse.c:1252, configuration.c:6961/7167,
frontend/drivers/platform_emscripten.c:620 - classifier
false positives (each _len is per-buffer reused, not
accumulated cross-buffer).1 parent e446242 commit 25ade82
4 files changed
Lines changed: 32 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
1119 | | - | |
| 1119 | + | |
| 1120 | + | |
1120 | 1121 | | |
1121 | 1122 | | |
1122 | | - | |
| 1123 | + | |
1123 | 1124 | | |
1124 | | - | |
| 1125 | + | |
1125 | 1126 | | |
1126 | | - | |
| 1127 | + | |
1127 | 1128 | | |
1128 | 1129 | | |
1129 | | - | |
1130 | | - | |
| 1130 | + | |
1131 | 1131 | | |
1132 | | - | |
1133 | | - | |
| 1132 | + | |
| 1133 | + | |
1134 | 1134 | | |
1135 | | - | |
| 1135 | + | |
1136 | 1136 | | |
1137 | | - | |
| 1137 | + | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
1141 | 1141 | | |
1142 | 1142 | | |
1143 | 1143 | | |
1144 | | - | |
| 1144 | + | |
1145 | 1145 | | |
1146 | | - | |
| 1146 | + | |
1147 | 1147 | | |
1148 | 1148 | | |
1149 | | - | |
| 1149 | + | |
1150 | 1150 | | |
1151 | 1151 | | |
1152 | 1152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4548 | 4548 | | |
4549 | 4549 | | |
4550 | 4550 | | |
4551 | | - | |
4552 | | - | |
4553 | | - | |
| 4551 | + | |
| 4552 | + | |
4554 | 4553 | | |
4555 | 4554 | | |
4556 | 4555 | | |
4557 | | - | |
| 4556 | + | |
4558 | 4557 | | |
4559 | 4558 | | |
4560 | | - | |
| 4559 | + | |
4561 | 4560 | | |
4562 | 4561 | | |
4563 | 4562 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3189 | 3189 | | |
3190 | 3190 | | |
3191 | 3191 | | |
3192 | | - | |
| 3192 | + | |
3193 | 3193 | | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
3194 | 3197 | | |
3195 | | - | |
| 3198 | + | |
3196 | 3199 | | |
3197 | 3200 | | |
3198 | 3201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2764 | 2764 | | |
2765 | 2765 | | |
2766 | 2766 | | |
2767 | | - | |
2768 | | - | |
2769 | | - | |
2770 | | - | |
2771 | | - | |
2772 | | - | |
2773 | | - | |
2774 | | - | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
2775 | 2777 | | |
2776 | 2778 | | |
2777 | 2779 | | |
| |||
0 commit comments