1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtdaemon.C |
2 | * File: rxvtdaemon.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
24 | #include <cstring> |
24 | #include <cstring> |
25 | #include <cstdio> |
25 | #include <cstdio> |
26 | |
26 | |
27 | #include <inttypes.h> |
27 | #include <inttypes.h> |
28 | #include <unistd.h> |
28 | #include <unistd.h> |
|
|
29 | #include <errno.h> |
|
|
30 | #include <sys/types.h> |
29 | #include <sys/utsname.h> |
31 | #include <sys/utsname.h> |
30 | #include <limits.h> |
32 | #include <limits.h> |
31 | |
33 | |
32 | #include "rxvtdaemon.h" |
34 | #include "rxvtdaemon.h" |
33 | |
35 | |
… | |
… | |
54 | |
56 | |
55 | void rxvt_connection::send (const char *data, int len) |
57 | void rxvt_connection::send (const char *data, int len) |
56 | { |
58 | { |
57 | uint8_t s[2]; |
59 | uint8_t s[2]; |
58 | |
60 | |
|
|
61 | if (len > 65535) |
|
|
62 | len = 65535; |
|
|
63 | |
59 | s[0] = len >> 8; s[1] = len; |
64 | s[0] = len >> 8; s[1] = len; |
60 | |
65 | |
61 | write (fd, s, 2); |
66 | write (fd, s, 2); |
62 | write (fd, data, len); |
67 | write (fd, data, len); |
63 | } |
68 | } |
… | |
… | |
74 | |
79 | |
75 | if (read (fd, s, 2) != 2) |
80 | if (read (fd, s, 2) != 2) |
76 | return false; |
81 | return false; |
77 | |
82 | |
78 | l = (s[0] << 8) + s[1]; |
83 | l = (s[0] << 8) + s[1]; |
79 | if (l > 4096) |
84 | if (l > 65535) |
80 | return false; |
85 | return false; |
81 | |
86 | |
82 | if (len) |
87 | if (len) |
83 | *len = l; |
88 | *len = l; |
84 | |
89 | |