Commit e01a672
Fix 4 code bugs: substr off-by-one, HANDLE* cast, TOCTOU GetLastError, sun_path overflow (#14297)
Bug 1 - LxssHttpProxy.cpp: IPv6 substr extraction used wrong length
calculation. substr(openBracket+1, closeBracket-1) is incorrect when
openBracket > 0; fixed to substr(openBracket+1, closeBracket-openBracket-1).
Also fixed empty-address guard to check closeBracket (not closeBracket-1).
Bug 2 - LxssUserSession.cpp: Two instances of reinterpret_cast<HANDLE*> in
ScopedMultiRelay construction should be reinterpret_cast<HANDLE> (without
the pointer). Other identical callsites in the same file already use the
correct cast.
Bug 3 - LxssUserSession.cpp: GetLastError() was called unconditionally after
CreateFileW, even on success. A stale ERROR_SHARING_VIOLATION from a prior
API call could cause a false throw. Fixed to only check GetLastError() when
CreateFileW fails (!vhd).
Bug 4 - plan9.cpp: sun_path bounds check used > instead of >= leaving no room
for null terminator. Also added a post-split check to ensure the child name
fits after splitting parent/child for long paths.
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>1 parent 55e04d5 commit e01a672
File tree
3 files changed
+16
-9
lines changed- src
- linux/init
- windows/service/exe
3 files changed
+16
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
330 | | - | |
| 330 | + | |
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1737 | 1737 | | |
1738 | 1738 | | |
1739 | 1739 | | |
1740 | | - | |
| 1740 | + | |
1741 | 1741 | | |
1742 | | - | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
1743 | 1748 | | |
1744 | | - | |
1745 | 1749 | | |
1746 | 1750 | | |
1747 | 1751 | | |
| |||
1949 | 1953 | | |
1950 | 1954 | | |
1951 | 1955 | | |
1952 | | - | |
| 1956 | + | |
1953 | 1957 | | |
1954 | 1958 | | |
1955 | 1959 | | |
| |||
2014 | 2018 | | |
2015 | 2019 | | |
2016 | 2020 | | |
2017 | | - | |
| 2021 | + | |
2018 | 2022 | | |
2019 | 2023 | | |
2020 | 2024 | | |
| |||
0 commit comments