More sizeof changes.
A couple more sizeof issues found and fixed. One of them is actually another protocol change, but due to a fortuitous accident it should remain compatible with older versions. Detailed explanation: When a client attempts to connect to a server that is already busy, the server is supposed to return ACCESS_DENIED as a state value. It was doing so, but was writing it as an int, even though state values are supposed to be signed chars. The client read the value correctly as a signed char, getting one byte and throwing away the rest. So why did this ever work? Because ACCESS_DENIED is the value -1, and any byte of an int -1 equals a signed char -1. If ACCESS_DENIED had been any other value, this would have been an opvious bug and would have long since been fixed. As is, it stuck around working by accident until now.
Этот коммит содержится в:
родитель
2944aaa05b
Коммит
4e2ef5070b
@ -110,7 +110,7 @@ int
|
||||
iperf_accept(struct iperf_test *test)
|
||||
{
|
||||
int s;
|
||||
int rbuf = ACCESS_DENIED;
|
||||
signed char rbuf = ACCESS_DENIED;
|
||||
char cookie[COOKIE_SIZE];
|
||||
socklen_t len;
|
||||
struct sockaddr_storage addr;
|
||||
@ -148,7 +148,7 @@ iperf_accept(struct iperf_test *test)
|
||||
i_errno = IERECVCOOKIE;
|
||||
return -1;
|
||||
}
|
||||
if (Nwrite(s, (char*) &rbuf, sizeof(int), Ptcp) < 0) {
|
||||
if (Nwrite(s, (char*) &rbuf, sizeof(rbuf), Ptcp) < 0) {
|
||||
i_errno = IESENDMESSAGE;
|
||||
return -1;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ iperf_tcp_accept(struct iperf_test * test)
|
||||
}
|
||||
|
||||
if (strcmp(test->cookie, cookie) != 0) {
|
||||
if (Nwrite(s, (char*) &rbuf, sizeof(signed char), Ptcp) < 0) {
|
||||
if (Nwrite(s, (char*) &rbuf, sizeof(rbuf), Ptcp) < 0) {
|
||||
i_errno = IESENDMESSAGE;
|
||||
return -1;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ delay(int64_t ns)
|
||||
|
||||
while (nanosleep(&req, &rem) == -1)
|
||||
if (EINTR == errno)
|
||||
memcpy(&req, &rem, sizeof rem);
|
||||
memcpy(&req, &rem, sizeof(rem));
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -90,7 +90,7 @@ set_tcp_windowsize(int sock, int bufsize, int dir)
|
||||
*/
|
||||
// printf("Setting TCP buffer to size: %d\n", bufsize);
|
||||
newbufsize = bufsize;
|
||||
rc = setsockopt(sock, SOL_SOCKET, dir, (char *) &newbufsize, sizeof newbufsize);
|
||||
rc = setsockopt(sock, SOL_SOCKET, dir, (char *) &newbufsize, sizeof(newbufsize));
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
} else {
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user