[ 
https://issues.apache.org/jira/browse/GUACAMOLE-608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Jumper updated GUACAMOLE-608:
-------------------------------------
    Description: 
{{guacd}} involves a {{__write_all}} function to write instruction 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:

{code:none}
int written = write(fd, buffer, length);
if (written < 0 || errno > 0)
    return -1;
{code}

  was:
`guacd` involves a `__write_all` function to write instruction 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 || errno > 0)
    return -1;
```


> 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, 1.0.0
>            Reporter: Changkun Ou
>            Priority: Major
>
> {{guacd}} involves a {{__write_all}} function to write instruction 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:
> {code:none}
> int written = write(fd, buffer, length);
> if (written < 0 || errno > 0)
>     return -1;
> {code}



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

Reply via email to