Changkun Ou created GUACAMOLE-608:
-------------------------------------

             Summary: Daemon process may encounter dead loop
                 Key: GUACAMOLE-608
                 URL: https://issues.apache.org/jira/browse/GUACAMOLE-608
             Project: Guacamole
          Issue Type: Bug
          Components: guacd
    Affects Versions: 0.9.14
            Reporter: Changkun Ou


`guacd` involves a `__write_all` function to write instruction to write as much 
as possible, see 
https://github.com/apache/guacamole-server/blob/7c191d7be0441a1cb64c90ab62d6535f3798eacb/src/guacd/connection.c#L67

However system call `write` may return 0 and set `errno`, which is not verified 
in the function.

A possible case: `write` keeps return 0 and nothing writes to buffer, therefore 
the daemon process encounters a dead loop, furthermore, it leads CPU rate up to 
99%.

A possible fix is:

```
int written = write(fd, buffer, length);
if (written < 0)
    return -1;
if (written == 0 && errno > 0)
    return -1;
```



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to