Commit 9e1ee380 for guacamole.apache.org
commit 9e1ee380601611101e5980eb0f7dc859fab98ab8
Author: Virtually Nick <vnick@apache.org>
Date: Sun Jul 5 15:01:01 2026 -0400
GUACAMOLE-2295: Check setsockopt and lseek return values.
diff --git a/src/guacd/daemon.c b/src/guacd/daemon.c
index 61b83e21..5e7d6c06 100644
--- a/src/guacd/daemon.c
+++ b/src/guacd/daemon.c
@@ -556,8 +556,9 @@ int main(int argc, char* argv[]) {
/* Set TCP_NODELAY to avoid any latency that would otherwise be added by the OS'
* networking stack and Nagle's algorithm */
const int SO_TRUE = 1;
- setsockopt(connected_socket_fd, IPPROTO_TCP, TCP_NODELAY,
- (const void*) &SO_TRUE, sizeof(SO_TRUE));
+ if (setsockopt(connected_socket_fd, IPPROTO_TCP, TCP_NODELAY,
+ (const void*) &SO_TRUE, sizeof(SO_TRUE)))
+ guacd_log(GUAC_LOG_WARNING, "Unable to set TCP_NODELAY on socket: %s", strerror(errno));
/* Create parameters for connection thread */
guacd_connection_thread_params* params = guac_mem_alloc(sizeof(guacd_connection_thread_params));
diff --git a/src/protocols/rdp/fs.c b/src/protocols/rdp/fs.c
index 8e9125e4..3003a18b 100644
--- a/src/protocols/rdp/fs.c
+++ b/src/protocols/rdp/fs.c
@@ -414,6 +414,7 @@ int guac_rdp_fs_open(guac_rdp_fs* fs, const char* path,
int guac_rdp_fs_read(guac_rdp_fs* fs, int file_id, uint64_t offset,
void* buffer, int length) {
+ off_t lseek_offset;
int bytes_read;
guac_rdp_fs_file* file = guac_rdp_fs_get_file(fs, file_id);
@@ -424,7 +425,9 @@ int guac_rdp_fs_read(guac_rdp_fs* fs, int file_id, uint64_t offset,
}
/* Attempt read */
- lseek(file->fd, offset, SEEK_SET);
+ lseek_offset = lseek(file->fd, offset, SEEK_SET);
+ if (lseek_offset < 0)
+ return guac_rdp_fs_get_errorcode(errno);
GUAC_RETRY_EINTR(bytes_read, read(file->fd, buffer, length));
/* Translate errno on error */
@@ -438,6 +441,7 @@ int guac_rdp_fs_read(guac_rdp_fs* fs, int file_id, uint64_t offset,
int guac_rdp_fs_write(guac_rdp_fs* fs, int file_id, uint64_t offset,
void* buffer, int length) {
+ off_t lseek_offset;
int bytes_written;
guac_rdp_fs_file* file = guac_rdp_fs_get_file(fs, file_id);
@@ -448,7 +452,9 @@ int guac_rdp_fs_write(guac_rdp_fs* fs, int file_id, uint64_t offset,
}
/* Attempt write */
- lseek(file->fd, offset, SEEK_SET);
+ lseek_offset = lseek(file->fd, offset, SEEK_SET);
+ if (lseek_offset < 0)
+ return guac_rdp_fs_get_errorcode(errno);
GUAC_RETRY_EINTR(bytes_written, write(file->fd, buffer, length));
/* Translate errno on error */