summaryrefslogtreecommitdiff
path: root/src/protocols/GammaControl.cpp
diff options
context:
space:
mode:
authorMrFantOlas <57408212+MrFantOlas@users.noreply.github.com>2025-07-18 23:20:17 +0200
committerGitHub <noreply@github.com>2025-07-18 23:20:17 +0200
commitae3cc48f223386b057137400354ed0ca1f7a8b1a (patch)
tree253573b0bf6a136d06a56c73c4735f67c6d5e8b1 /src/protocols/GammaControl.cpp
parent4adf65890766b482afbaafa90140d72f7b5845d9 (diff)
protocols/gamma: support pipes (#11076)
Add support for pipes and potentially other valid file descriptors. Add check for more data on the socket than the required amount as per protocol. --------- Co-authored-by: Alexandre Teixeira <alexandre.teixeira@etu.emse.fr>
Diffstat (limited to 'src/protocols/GammaControl.cpp')
-rw-r--r--src/protocols/GammaControl.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp
index 29a9cae4..e371496d 100644
--- a/src/protocols/GammaControl.cpp
+++ b/src/protocols/GammaControl.cpp
@@ -71,11 +71,19 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
return;
}
- ssize_t readBytes = pread(gammaFd.get(), m_gammaTable.data(), m_gammaTable.size() * sizeof(uint16_t), 0);
- if (readBytes < 0 || (size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) {
+ ssize_t readBytes = read(gammaFd.get(), m_gammaTable.data(), m_gammaTable.size() * sizeof(uint16_t));
+
+ ssize_t moreBytes = 0;
+ {
+ const size_t BUF_SIZE = 1;
+ char buf[BUF_SIZE] = {};
+ moreBytes = read(gammaFd.get(), buf, BUF_SIZE);
+ }
+
+ if (readBytes < 0 || (size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t) || moreBytes != 0) {
LOGM(ERR, "Failed to read bytes");
- if ((size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) {
+ if ((size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t) || moreBytes > 0) {
gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch");
return;
}